#8

pawn Код:
CMD:rob(playerid, params[])
{
    new targetid,name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME],string[60],Float:x, Float:y, Float:z;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /rob [id]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    new tPos = GetPlayerPos(targetid, x, y, z);
    if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "This player is too far away");
    if(GetPlayerMoney(targetid) < 1000) return SendClientMessage(playerid, COLOR_RED, "This player doesn't have enough money");
    else
    {
        new money = GetPlayerMoney(targetid);
        GivePlayerMoney(playerid, money / 10);
        GivePlayerMoney(targetid, -money / 10);
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(targetid, name2, sizeof(name2));
        format(string,sizeof(string),"%s has robbed %s",name, name2);
        SendClientMessageToAll(COLOR_GREEN,string);
        format(string,sizeof(string),"You robbed $%d", money/10);
        SendClientMessage(playerid,COLOR_SILVER,string);
        format(string,sizeof(string),"You got robbed and lost $%d", money/10);
        SendClientMessage(targetid,COLOR_SILVER,string);
    }
    return 1;
}
I tend to write commands in that style. Personally, I see nothing wrong, but if something is crashing your server, I recommend using crashdetect https://sampforum.blast.hk/showthread.php?tid=262796 to see what's causing the problem.
Reply


Messages In This Thread
Rob - by nezo2001 - 05.01.2015, 11:09
Re: Rob - by Banana_Ghost - 05.01.2015, 11:25
Re: Rob - by nezo2001 - 05.01.2015, 11:31
Re: Rob - by Banana_Ghost - 05.01.2015, 11:33
Re: Rob - by nezo2001 - 05.01.2015, 11:35
Re: Rob - by Banana_Ghost - 05.01.2015, 11:37
Re: Rob - by nezo2001 - 05.01.2015, 11:49
Re: Rob - by Banana_Ghost - 05.01.2015, 11:56
Re: Rob - by nezo2001 - 05.01.2015, 12:13
Re: Rob - by Banana_Ghost - 05.01.2015, 12:16

Forum Jump:


Users browsing this thread: 1 Guest(s)