SA-MP Forums Archive
Help with SSCANF and DCMD - 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: Help with SSCANF and DCMD (/showthread.php?tid=97610)



Help with SSCANF and DCMD - almighty - 15.09.2009

Hi there.... im working again with samp and getting use to it.... im testing sscanf, trying to make a ENGINE ON/OF command and i've got this....
Код:
dcmd_engine(playerid,params[])
{
 new State[50];
 if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,RED,"You must be in a vehicle!");
 if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid,RED,"You must be the Driver of the vehicle!");
 if(sscanf(params[0],"s",State))
 {
  SendClientMessage(playerid,RED,"Usage: '/engine (on-off)'");
 	return 1;
 }
 if(State,"ON",true)) // (State == "On") or (State == "oN") or State == "on" ***********************************
 {
 	SendClientMessage(playerid,GREEN,"Turning the Engine ON, Please Stand By");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,GREEN,"The vehicle is ON!");
 }
 return 1;
}
the problem is i get this error
Код:
C:\Users\Walter\Desktop\GTA SAMP SERver\gamemodes\Test.pwn(225) : warning 206: redundant test: constant expression is non-zero
C:\Users\Walter\Desktop\GTA SAMP SERver\gamemodes\Test.pwn(225) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Line 225 is the one with the Stars.......


Re: Help with SSCANF and DCMD - _Vortex - 15.09.2009

Wich line is 225?

Edit: sorry, didn't read "line 225 is bla bla"

Код:
dcmd_engine(playerid,params[])
{
 new State[50];
 if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,RED,"You must be in a vehicle!");
 if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid,RED,"You must be the Driver of the vehicle!");
 if(sscanf(params[0],"s",State))
 {
  SendClientMessage(playerid,RED,"Usage: '/engine (on-off)'");
 	return 1;
 }
 if(State,"ON",true)) // (State == "On") or (State == "oN") or (State == "on")
 {
 	SendClientMessage(playerid,GREEN,"Turning the Engine ON, Please Stand By");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,ORANGE,"*");
	SendClientMessage(playerid,GREEN,"The vehicle is ON!");
 }
 return 1;
}
try that, (not tested)


Re: Help with SSCANF and DCMD - Clavius - 15.09.2009

strcmp


Re: Help with SSCANF and DCMD - Calgon - 15.09.2009

pawn Код:
if(!strcmp(State, "on", true))