Command problems with ID 0
#1

Hello. I am currently making a CnR script.
It all seemd good until a few mins ago where i with a friend tested alittle on it.
When using 1 of the commands on ID 0 it thinks i dont write a ID

Heres an example of 1 of the commands

Код:
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;
					}
				}
			}
		}
	}
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Seif_ [adream-rp.com
]
First: use zcmd instead of dcmd.
Second: don't use strtok in dcmd/zcmd; use sscanf.
Hmm okay will have a look at it

Quote:
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.
No that just checks if your an robber. If you arent it will send you server unknown command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)