Simple test cmds - 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)
+--- Thread: Simple test cmds (
/showthread.php?tid=440184)
Simple test cmds -
Jay_Dixon - 28.05.2013
Ok, i'm trying to see if i can make it so only people with a certain name can use it, i've seen it done before, and everything i'm trying won't work. What am i doing wrong?
Код:
CMD:test(playerid)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(strcmp("Jay_Dixon,"playername, true, 10) == 0)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, " YOU'RE NOT JAY!");
}
return 1;
}
Код:
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 001: expected token: ";", but found ")"
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 029: invalid expression, assumed zero
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
AW: Simple test cmds -
HurtLocker - 28.05.2013
if (strcmp("Jay_Dixon", playername, true, 10) == 0) and i tell you for info that the string's length (10) is optional parameter.
Re: Simple test cmds -
zxc1 - 28.05.2013
pawn Код:
CMD:test(playerid)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(strcmp("Jay_Dixon",playername, false) == 0)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, " YOU'RE NOT JAY!");
}
return 1;
}
Re: Simple test cmds -
TheStreetsRP - 28.05.2013
Everyone else got to it, but you have the comma inside of the quotes in this line:
Код:
if(strcmp("Jay_Dixon,"playername, true, 10) == 0)
Also as stated, I would remove the 10. I also like writing mine as such:
Код:
if(!strcmp("Jay_Dixon", playername, true))
Does the same thing, checks for zero.
Re: Simple test cmds -
SilverKiller - 28.05.2013
Try :
pawn Код:
CMD:test(playerid)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(!strcmp("Jay_Dixon", playername, true))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, " YOU'RE NOT JAY!");
}
return 1;
}
EDIT: Late, Late, Too late.