SA-MP Forums Archive
ID 0.... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ID 0.... (/showthread.php?tid=86454)



ID 0.... - DevilRevenge - 14.07.2009

Hello!
I try to do drift system.
some player invite other one.
the problem is the ID 0 can invite anyone,but no1 can invite Id 0...
This is the code:
Код:
new cmd[256],idx;
	cmd=strtok(cmdtext,idx);
	if(strcmp(cmd,"/startdrift", true)==0)
	{
	new tmp[256],str[256],str2[256],sname[MAX_PLAYER_NAME],rname[MAX_PLAYER_NAME];
	tmp=strtok(cmdtext,idx);
	if(!strval(tmp)) return SendClientMessage(playerid,COLOR_RED,"/startdrift playerid - USAGE");
	else {
	
	rid=strval(tmp);
	
 	 if(Host[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You are in drift!");
 	
 	else if(DriftOn == 1) return SendClientMessage(playerid,COLOR_RED,"The drift have started.");
 	else if(Invited[rid] == 1) return SendClientMessage(playerid,COLOR_RED,"You have already sent invitaion or someone have.");
	else if(rid == INVALID_PLAYER_ID || IsPlayerConnected(rid) == 1 || rid != playerid)
	{
	sid=playerid;
	GetPlayerName(playerid,sname,sizeof(sname));
	GetPlayerName(rid,rname,sizeof(rname));
	format(str,sizeof(str),"You have sent a invitaion to %s for drift",rname);
	SendClientMessage(playerid,COLOR_ORANGE,str);
	format(str2,sizeof(str2),"%s invited you for drift",sname);
	SendClientMessage(rid,COLOR_YELLOW,str2);
	Invited[rid]=1;
	return 1;
	}
	else return SendClientMessage(playerid,COLOR_RED,"You can't send it to yourself,or desconnect players.");
	}
	}
The error that ID 1 get when he try to send invitaion to ID 0 is " /startdrift playerid - USAGE"..

Thanks for helping!


Re: ID 0.... - Vince - 14.07.2009

Код:
if(!strval(tmp)) return SendClientMessage(playerid,COLOR_RED,"/startdrift playerid - USAGE");
Translated would that be: if not 0 return SendClientMessage ...

So replace with:
Код:
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"/startdrift playerid - USAGE");



Re: ID 0.... - DevilRevenge - 14.07.2009

Great! Thanks!