30.03.2009, 13:14
pawn Код:
if(strcmp(cmd, "/pay", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "/pay [playerid/PartOfName] [amount]");
return 1;
}
//giveplayerid = strval(tmp);
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "/pay [playerid/PartOfName] [amount]");
return 1;
}
new moneys,playermoney;
moneys = strval(tmp);
if(PlayerInfo[playerid][pAdmin] < 1)
{
if(moneys > 999999999 && PlayerInfo[playerid][pLevel] < 5)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You need to be level 5 to make that transition.");
return 1;
}
}
if(moneys < 1 || moneys > 999999999)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Invбlid Ammount");
return 1;
}
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if (ProxDetectorS(5.0, playerid, giveplayerid))
{
if(giveplayerid != playerid)
{
playermoney = GetPlayerCash(playerid);
if (moneys > 0 && playermoney >= moneys)
{
GivePlayerCash(playerid, (0 - moneys));
GivePlayerCash(giveplayerid, moneys);
format(string, sizeof(string), "You gave %s(Player: %d), %d$.", moneys, GetPlayerNameEx(giveplayerid),giveplayerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "You recieved %d$ from %s(Player: %d).",GetPlayerNameEx(playerid), playerid,moneys);
SendClientMessage(giveplayerid, COLOR_WHITE, string);
format(string, sizeof(string), "%s payed %d$ a %s", GetPlayerNameEx(playerid), moneys, GetPlayerNameEx(giveplayerid));
PayLog(string);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
PlayerPlayerActionMessage(playerid,giveplayerid,5.0,"%s takes out his wallet and gives some cash to %s.");
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Invбlid ammount");
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You can't pay to yourself dumbass!");
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "You're to far away.");
}
}//invalid id
}
else
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Invбlid ID");
}
}
return 1;
}