strfind help - 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: strfind help (
/showthread.php?tid=570545)
strfind help -
nicholasramdhan - 11.04.2015
For some reason, if the person has [CIA] in their name, and they spawn, they still don't get the message that says "You have spawned as an official Central Intelligence Agency clan member" any help?
Код:
case 32..35: {
new name[ MAX_PLAYER_NAME ];
SetPlayerPos(playerid,2752.8835,-2513.6389,25.7914);
SetPlayerCameraPos(playerid,2753.1050,-2519.0244,26.6926);
SetPlayerCameraLookAt(playerid,2752.8835,-2513.6389,25.7914);
SetPlayerFacingAngle(playerid,180.0);
GameTextForPlayer(playerid, "~y~[RESTRICTED] Central Intelligence Agency", 3000, 3);
ApplyAnimation(playerid,"GYMNASIUM", "GYMshadowbox",4.0,1,1,1,1,1);
if(strfind(name,"[CIA]",true) != -1)
{
SendClientMessage(playerid, HOODLUMS_COLOR, "You have spawned as an official Central Intelligence Agency clan member.");
return 1;
}
}
Re: strfind help -
Konstantinos - 11.04.2015
"name" is null because you don't get the player's name anywhere.
pawn Код:
new name[ MAX_PLAYER_NAME ];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strfind(name,"[CIA]",true) != -1)
...
AW: strfind help -
Mencent - 11.04.2015
Hello!
Write it in the following way:
PHP код:
case 32..35:
{
new name[MAX_PLAYER_NAME];
SetPlayerPos(playerid,2752.8835,-2513.6389,25.7914);
SetPlayerCameraPos(playerid,2753.1050,-2519.0244,26.6926);
SetPlayerCameraLookAt(playerid,2752.8835,-2513.6389,25.7914);
SetPlayerFacingAngle(playerid,180.0);
GameTextForPlayer(playerid,"~y~[RESTRICTED] Central Intelligence Agency",3000,3);
ApplyAnimation(playerid,"GYMNASIUM","GYMshadowbox",4.0,1,1,1,1,1);
GetPlayerName(playerid,name,sizeof name);
if(strfind(name,"[CIA]",true) != -1)
{
SendClientMessage(playerid, HOODLUMS_COLOR, "You have spawned as an official Central Intelligence Agency clan member.");
return 1;
}
}
You have forgot to read out the name with GetPlayerName.
Mencent