String help :p - 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: String help :p (
/showthread.php?tid=160904)
String help :p -
[NTX]MikeQ - 18.07.2010
I was trying to vreate a anti attacker alarm in my A51 server but i didnt have time and i didnt get how to format a string correctly i just took a string of and FS so here it is:
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, 249.0186,1842.6013,8.7672))
{
CreateExplosion(249.0186,1842.6013,8.7672, 2, Float:5)
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
new string[128]; new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s Was Exploded by the anti attack!", playerName);
SendClientMessage(i, COLOR_RED, string);
}
/facepalm
And i get these errors:
pawn Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(124) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(127) : error 001: expected token: ";", but found "}"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(128) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(131) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(136) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(286) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(290) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(389) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(390) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(502) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
3 Errors.
Re: String help :p -
iggy1 - 18.07.2010
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, 249.0186,1842.6013,8.7672))
{
CreateExplosion(249.0186,1842.6013,8.7672, 2, Float:5);
new string[128]; new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s Was Exploded by the anti attack!", playerName);
SendClientMessageToAll(COLOR_RED, string);
}
might be a better way of doing that.
EDIT: Or try this:
At bottom of script
pawn Код:
stock playername(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
return pname;
}
wherever you put this.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, 249.0186,1842.6013,8.7672))
{
CreateExplosion(249.0186,1842.6013,8.7672, 2, Float:5);
new string[128];
format(string, sizeof(string), "%s Was Exploded by the anti attack!", playerName(playerid));
SendClientMessageToAll(COLOR_RED, string);
}
That how id do it. The playername functon is exelent.
Re: String help :p -
[NTX]MikeQ - 18.07.2010
Ok ill try
Re: String help :p -
[NTX]MikeQ - 18.07.2010
i got this
pawn Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(124) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(127) : error 001: expected token: ";", but found "new"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(128) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(282) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(286) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(385) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(386) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(498) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
3 Errors.
Re: String help :p -
iggy1 - 18.07.2010
edited my post try that.
Re: String help :p -
Hamza' - 18.07.2010
REMOVE PLZ, wrong topic
Re: String help :p -
iggy1 - 18.07.2010
Quote:
Originally Posted by Hamza'
REMOVE PLZ, wrong topic
|
What? Oh BTW you forgot to semi colon createxplosion dont forget to add ;
EDIT: one last thing, what callback/function have you placed this code?
Re: String help :p -
[NTX]MikeQ - 18.07.2010
now i got this
pawn Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(124) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(128) : error 017: undefined symbol "playerName"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(220) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(280) : warning 219: local variable "playerName" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(281) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(285) : warning 211: possibly unintended assignment
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(312) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(331) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(384) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(385) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\BreakIn.pwn(497) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
Re: String help :p -
iggy1 - 18.07.2010
Try this
pawn Код:
stock playaname(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
return pname;
}
It seems you already have a variable called playername in ur script. Also you might be getting the "Undefined symbol playerid" error because you have put your code in the wrong callback, what callback is your code in?
Re: String help :p -
[NTX]MikeQ - 18.07.2010
You have teamviewer?
its easier than posting all the time