ID 0....
#1

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!
Reply
#2

Код:
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");
Reply
#3

Great! Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)