String help :p
#1

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

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.
Reply
#3

Ok ill try
Reply
#4

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.
Reply
#5

edited my post try that.
Reply
#6

REMOVE PLZ, wrong topic
Reply
#7

Quote:
Originally Posted by Hamza'
Посмотреть сообщение
REMOVE PLZ, wrong topic
What? Oh BTW you forgot to semi colon createxplosion dont forget to add ;

pawn Код:
CreatExplosion(blabla);
EDIT: one last thing, what callback/function have you placed this code?
Reply
#8

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.
Reply
#9

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?
Reply
#10

You have teamviewer?
its easier than posting all the time
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)