SA-MP Forums Archive
name in sendclientmessage - 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: name in sendclientmessage (/showthread.php?tid=87090)



name in sendclientmessage - [mad]MLK - 18.07.2009

hey so basicaly i want this line to say (playername) Has just stole a couch ! to all players so how would i get this code line to say there name at the start ?
Код:
SendClientMessageToAll(0x33AA33AA, "playersnamehere has just stole a hobo's couch!");



Re: name in sendclientmessage - Annihalation - 18.07.2009

you would format a string

add this at the top of your couch stealing code

Код:
new pname[24], string[128];
GetPlayerName(playerid, pname, sizeof(pname);
format(string, sizeof(string), "%s has just stole a couch!", pname);
and change your "SendClientMessageToAll", "(player name) has just stole a couch!", change that to string (no quotes

should look like this

Код:
SendClientMessageToAll(<color>, string);
put your color in where <color> is


Re: name in sendclientmessage - [mad]MLK - 18.07.2009

hey i get this error with that line
Код:
C:\Documents and Settings\Chris\Desktop\Stunt City\gamemodes\NewServer.pwn(543) : error 001: expected token: ",", but found ";"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
    if (pickupid == skate)
    {
        new pname[24], string[128];
        format(string, sizeof(string), "%s has just stole a hobo's couch!", pname);
        GetPlayerName(playerid, pname, sizeof(pname);
        SendClientMessageToAll(0x33AA33AA, string);
        SendClientMessage(playerid, 0xFFA500AA, "Look on the bright side, you sold the couch on eBay for $400");
        GivePlayerMoney(playerid, 400);
        SetPlayerWantedLevel(playerid, 3);
        GameTextForPlayer(playerid,"Couch Theif",5000,3);

        
    }
line 543 is GetPlayerName(playerid, pname, sizeof(pname);


Re: name in sendclientmessage - Vince - 18.07.2009

Add a ) just before the ;


Re: name in sendclientmessage - [mad]MLK - 18.07.2009

hmm it dont say there name it just dose this



Re: name in sendclientmessage - member - 18.07.2009

The GetPlayerName should be before the format line i think. If that don't work try this:

pawn Код:
new string[128], adminname[MAX_PLAYER_NAME];
        GetPlayerName(playerid,adminname,sizeof(adminname));
        format(string, sizeof(string), "%s has just stole a hobo's couch!",adminname);
        SendClientMessageToAll(0x33AA33AA, string);




Re: name in sendclientmessage - yom - 18.07.2009

Look carefully these lines:
pawn Код:
new pname[24], string[128];
format(string, sizeof(string), "%s has just stole a hobo's couch!", pname);
GetPlayerName(playerid, pname, sizeof(pname);
You use GetPlayerName AFTER formatting.. so at the moment format() is called, pname is empty.


Re: name in sendclientmessage - [mad]MLK - 18.07.2009

hmm still dosent show the name


Re: name in sendclientmessage - member - 18.07.2009

Quote:
Originally Posted by [mad
MLK ]
hmm still dosent show the name
Did you read what he said?

Quote:
Originally Posted by 0rb
Look carefully these lines:
pawn Код:
new pname[24], string[128];
format(string, sizeof(string), "%s has just stole a hobo's couch!", pname);
GetPlayerName(playerid, pname, sizeof(pname);
You use GetPlayerName AFTER formatting.. so at the moment format() is called, pname is empty.
Change the order of the format and the GetPlayername so it looks like this:
pawn Код:
new pname[24], string[128];
GetPlayerName(playerid, pname, sizeof(pname);
format(string, sizeof(string), "%s has just stole a hobo's couch!", pname);