23.07.2012, 16:03
Hey all
I have this command
and it sells a car owned by a player to other /venderveiculo ID MONEY, but my problem is that the players can sell with negative values and the player who buy the car wins the money which was negative.
Example:
/venderveiculoplayer 0 -1000000
ID 0 wins 100000$ and ID 1 (seller) wins 0.
How can I prevent it?
I have this command
pawn Код:
if(strcmp(cmd, "/venderveiculoplayer", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USO:] /venderveiculoplayer [playerid/PartOfName] [Nє da Chave] [Preзo]");
return 1;
}
new playa;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USO:] /venderveiculoplayer [playerid/PartOfName] [Nє da Chave] [Preзo]");
return 1;
}
new ckey;
ckey = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USO:] /venderveiculoplayer [playerid/PartOfName] [Nє da Chave] [Preзo]");
return 1;
}
new cost;
cost = strval(tmp);
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
if (ProxDetectorS(5.0, playerid, playa))
{
if(ckey >=1 && ckey <=6)
{
if(ckey == 1 || ckey == 3 || ckey == 5)
{
if(ckey == 1)
{
if(PlayerInfo[playerid][pChave] == 255)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Erro:] Nгo tens carro na chave 1.");
return 1;
}
}
if(ckey == 3)
{
if(PlayerInfo[playerid][pChave3] == 255)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Erro:] Nгo tens carro na chave 3.");
return 1;
}
}
if(ckey == 5)
{
if(PlayerInfo[playerid][pChave5] == 255)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Erro:] Nгo tens carro na chave 3.");
return 1;
}
}
if(playa == playerid) { SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERRO:] Nao podes vender a ti mesmo!"); return 1; }
format(string, sizeof(string), "[INFO:] Perguntaste a %s se quer comprar o teu carro.", GetPlayerNameEx(playa));
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "[INFO:] %s quer vender o carro %d por $%d.", GetPlayerNameEx(playerid), ckey, cost);
SendClientMessage(playa, COLOR_WHITE, string);
SendClientMessage(playa, COLOR_LIGHTYELLOW2, "[INFO:] Faz /aceitar veiculo, Para comprares o carro.");
SellCarOffer[playa] = playerid;
SellCarPrice[playa] = cost;
SellCarKey[playa] = ckey;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Erro:] Nгo podes vender carros emprestados.");
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Erro:] ID Invalido.");
}
}
else
{
SendClientMessage(playa, COLOR_LIGHTYELLOW2, "[INFO:] Estбs muito longe do player.");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERRO:] ID Invalido.");
}
}
return 1;
}
Example:
/venderveiculoplayer 0 -1000000
ID 0 wins 100000$ and ID 1 (seller) wins 0.
How can I prevent it?