dcmd_rob(playerid,params[])
{
if(robber[playerid] == 0)
{
return 0;
}
else
{
new tmp[255],idx;
tmp = strtok(params,idx);
if(!strval(tmp))
{
SendClientMessage(playerid,COLOUR_RED,"USAGE: /rob [ID]");
return 1;
}
else
{
pid = strval(tmp);
if(!IsPlayerConnected(pid))
{
SendClientMessage(playerid,COLOUR_RED,"ERROR: Player is not connected");
return 1;
}
else
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(pid,X,Y,Z);
if(!PlayerToPoint(5,playerid,X,Y,Z))
{
SendClientMessage(playerid,COLOUR_RED,"ERROR: You are to far away too rob targeted ID");
return 1;
}
if(robtimer[playerid] == 1)
{
SendClientMessage(playerid,COLOUR_RED,"ERROR: You must wait before robbing again!");
return 1;
}
else
{
robtimer[playerid] = 1;
new ammount,string[100],string1[120],name[MAX_PLAYER_NAME],name1[MAX_PLAYER_NAME];
ammount = GetPlayerMoney(playerid)/2;
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(pid,name1,sizeof(name1));
GivePlayerMoney(pid,-ammount);
GivePlayerMoney(playerid,ammount);
format(string,sizeof(string),"You have succesfully robbed %s from %s",ammount,name1);
format(string1,sizeof(string1),"You have been robbed %s by %s",ammount,name);
SendClientMessage(playerid,COLOUR_YELLOW,string);
SendClientMessage(pid,COLOUR_RED,string1);
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+1);
SetTimer("robtimerone",120000,false);
return 1;
}
}
}
}
}
|
Originally Posted by Seif_ [adream-rp.com
]
First: use zcmd instead of dcmd. Second: don't use strtok in dcmd/zcmd; use sscanf. |
|
Originally Posted by www.trueroleplay.com
if(robber[playerid] == 0)
{ return 0; } Is that a problem? If that has anything to do with the ID. If its ID 0, it just returns 0. |