Help please :)[REP] -
Excelize - 23.01.2014
Hello,
I wanna make a message saying "%s has teleported to /LSA" and Send it to all players.
This is the code I have so far:
pawn Код:
CMD:lsa(playerid, params[])
{
SetPlayerPos(playerid,1706.821045, -2466.476807, 13.554688);
GameTextForPlayer(playerid, "~r~LSA", 3000, 6);
return 1;
}
And I just need the SendClientMessageToAll part and for it to be able to get the player's name.
Thanks
PS: Sorry for the [REP+] on the top of the topic, my questions don't usually get answered :c
Re: Help please :)[REP] -
Hoborific - 23.01.2014
pawn Код:
new Player[MAX_PLAYER_NAME],str[128];
GetPlayerName(playerid, Player, sizeof(Player) );
format(str,sizeof(str),"%s has teleported to /LSA", Player);
SendClientMessageToAll(COLOR,str);
Re: Help please :)[REP] -
Excelize - 23.01.2014
Thanks for the reply, But i get:
Код:
warning 219: local variable "str" shadows a variable at a preceding level
What does this warning mean?
Re: Help please :)[REP] -
Hoborific - 23.01.2014
rename all instances of str in my code to strtemp,
pawn Код:
new Player[MAX_PLAYER_NAME],strtemp[128];
GetPlayerName(playerid, Player, sizeof(Player) );
format(strtemp,sizeof(strtemp),"%s has teleported to /LSA", Player);
SendClientMessageToAll(COLOR,strtemp);
I also recommend not using things such as STR on a global level as they usually indicate a temporary string not important enough to be named.
Re: Help please :)[REP] -
Excelize - 23.01.2014
Seriously, thanks a lot for the help. But when I do /lsa In-game, it just says " has teleported to LSA".
So it's not loading the name properly..
Re: Help please :)[REP] -
Hoborific - 23.01.2014
Please post the whole command, I can't see where you could have gone wrong.
Re: Help please :)[REP] -
Excelize - 23.01.2014
pawn Код:
CMD:lsa(playerid, params[])
{
SetPlayerPos(playerid,1706.821045, -2466.476807, 13.554688);
GameTextForPlayer(playerid, "~r~LSA", 3000, 6);
format(strtemp,sizeof(strtemp),"%s has teleported to {F5FF00}/LSA", Player);
SendClientMessageToAll(blue,strtemp);
return 1;
}
Here
Re: Help please :)[REP] -
Hoborific - 23.01.2014
pawn Код:
CMD:lsa(playerid, params[])
{
new Player[MAX_PLAYER_NAME+1],strtemp[128];
SetPlayerPos(playerid,1706.821045, -2466.476807, 13.554688);
GameTextForPlayer(playerid, "~r~LSA", 3000, 6);
format(strtemp,sizeof(strtemp),"%s has teleported to {F5FF00}/LSA", Player);
SendClientMessageToAll(blue,strtemp);
return 1;
}
Those are local variables that do not and should not exceed the local scope of the command , making them global can cause a lot of issues, Please delete wherever you added them to, and add them into the command as I have shown above. I've also increased the size of MAX_PLAYERNAME to MAX_PLAYERNAME+1 because the wiki informed me that the define for MAX_PLAYERNAME does not include the terminating char, causing max character playername to be one letter short.
Re: Help please :)[REP] -
Excelize - 23.01.2014
Nope, still doesn't work, but I'll just get it from an old GM. Thanks for the help anyways.
Re: Help please :)[REP] -
J4mmyHD - 23.01.2014
pawn Код:
CMD:lsa(playerid, params[])
{
new Player[MAX_PLAYER_NAME+1],strtemp[128];
GetPlayerName(playerid, Player, sizeof(Player))
SetPlayerPos(playerid,1706.821045, -2466.476807, 13.554688);
GameTextForPlayer(playerid, "~r~LSA", 3000, 6);
format(strtemp,sizeof(strtemp),"%s has teleported to {F5FF00}/LSA", Player);
SendClientMessageToAll(blue,strtemp);
return 1;
}