Help please :)[REP]
#1

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

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);
Reply
#3

Thanks for the reply, But i get:
Код:
warning 219: local variable "str" shadows a variable at a preceding level
What does this warning mean?
Reply
#4

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

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

Please post the whole command, I can't see where you could have gone wrong.
Reply
#7

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
Reply
#8

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

Nope, still doesn't work, but I'll just get it from an old GM. Thanks for the help anyways.
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)