Под какими наркотиками ты писал этот код?
Как-то так
PHP код:
CMD:cmd(playerid, params[])
{
new giveplayerid,
price;
if(sscanf(params, "ud", giveplayerid, price))
return SendClientMessage(playerid, COLOR_RED, "Пример: /cmd [id] [цена]");
if(price < 100 || price > 300)
return SendClientMessage(playerid, COLOR_RED, "Цена ниже 100 выше 300");
if(giveplayerid == playerid)
return SendClientMessage(playerid, COLOR_RED, "Вы указали свой айди");
if(GetPVarInt(playerid, "Start_Of_Something"))
return SendClientMessage(playerid, COLOR_RED, "Данному игроку уже предложили сделать *это*");
new string[27+MAX_PLAYER_NAME+11];
format(string, sizeof(string),"Вы предложили %s сделать за %d$", player[giveplayerid][pName], price);
SendClientMessage(playerid, COLOR_RED, string);
format(string, sizeof(string), "%s предлагает сделать за %d", player[playerid][pName], price);
SendClientMessage(giveplayerid, COLOR_RED, string);
SetPVarInt(giveplayerid, "Start_Of_Something", 1);
SetPVarInt(giveplayerid, "Something_ID", playerid);
SetPVarInt(giveplayerid, "Something_Price", price);
return 1;
}
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_YES)
{
if(GetPVarInt(playerid, "Start_Of_Something"))
{
if(!IsPlayerConnected(GetPVarInt(playerid, "Something_ID")))
{
SendClientMessage(playerid, -1, "Игрок, предложивший Вам какие-то услуги, покинул сервер");
DeletePVar(playerid, "Start_Of_Something");
DeletePVar(playerid, "Something_ID");
DeletePVar(playerid, "Something_Price");
return 1;
}
/*
...
...
GivePlayerMoney(GetPVarInt(playerid, "Something_ID"), GetPVarInt(playerid, "Something_Price"));
Нужное действие при согласии
...
...
*/
new string[49+MAX_PLAYER_NAME+11];
format(string, sizeof(string), "Вы согласились на какие-то услуги от игрока %s за %d$", player[GetPVarInt(playerid, "Something_ID")][pName], GetPVarInt(playerid, "Something_Price"));
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "Игрок %s согласился на ваши услуги. Вы получили %d$", player[playerid][pName], GetPVarInt(playerid, "Something_Price"));
SendClientMessage(GetPVarInt(playerid, "Something_ID"), -1, string);
DeletePVar(playerid, "Start_Of_Something");
DeletePVar(playerid, "Something_ID");
DeletePVar(playerid, "Something_Price");
return 1;
}
}
else if(newkeys & KEY_NO)
{
if(GetPVarInt(playerid, "Start_Of_Something"))
{
if(!IsPlayerConnected(GetPVarInt(playerid, "Something_ID")))
{
SendClientMessage(playerid, -1, "Игрок, предложивший Вам какие-то услуги, покинул сервер");
DeletePVar(playerid, "Start_Of_Something");
DeletePVar(playerid, "Something_ID");
DeletePVar(playerid, "Something_Price");
return 1;
}
/*
...
Нужное действие при отказе
...
...
*/
new string[42+MAX_PLAYER_NAME];
format(string, sizeof(string), "Вы отказались от каких-то услуг от игрока %s", player[GetPVarInt(playerid, "Something_ID")][pName]);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "Игрок %s отказался от ваших услуг.", player[playerid][pName]);
SendClientMessage(GetPVarInt(playerid, "Something_ID"), -1, string);
DeletePVar(playerid, "Start_Of_Something");
DeletePVar(playerid, "Something_ID");
DeletePVar(playerid, "Something_Price");
return 1;
}
}
return 1;
}