/r help - string/params - stuck
#1

No idea if it is string or params, but either way i can't get it to work..

I have 3 thing's set up, no idea what there called but yeah, it's for my LSPD Faction, command:
Quote:

CMD:r(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[160];
new lspdrank = PlayerInfo[playerid][pLSPD];
if(!(PlayerInfo[playerid][pLSPD] >= 1)) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
if(isnull(params)) return SCM(playerid,COLOR_WHITE,"USAGE: /r [radio chat]");
GetPlayerName(playerid,sendername,sizeof(sendernam e));
sendername[strfind(sendername,"_")] = ' ';
format(string,160,"* (R%d) %s: %s",PlayerInfo[playerid][pLSPD],lspdrank, params, sendername);
SendLSPDMessage(COLOR_LIGHTBLUE, string);
return 1;
}

I made the text bold the 3 thing's I am on about, and underlined the line that it's all on, no errors or anything but when i type /r texthere - it says the rank so like: * (R1) : Texthere - For some reason the name doesn't show up?

Any help please, the name wont appear, although the rank and the text does

EDIT: Also if I changed the * (R%d) %s: %s to a %i or a %d it says 1, presuming because of the rank, so can anyone help?
Reply
#2

pawn Код:
CMD:r(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME], string[160];
    new lspdrank = PlayerInfo[playerid][pLSPD];
    if(!(PlayerInfo[playerid][pLSPD] >= 1)) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
    if(isnull(params)) return SCM(playerid,COLOR_WHITE,"USAGE: /r [radio chat]");
    GetPlayerName(playerid,sendername,sizeof(sendernam e));
    sendername[strfind(sendername,"_")] = ' ';
    format(string,160,"* (R%d) %s: %s",lspdrank, sendername, params);
    SendLSPDMessage(COLOR_LIGHTBLUE, string);
    return 1;
}
For future reference, use [ pawn] [ /pawn] tags (without the space).

It obviously wouldn't work, the format was wrong. Plus, why would you have 4 things to input into the line when there are only 3 placeholders (%s, %i, etcetra).
Reply
#3

I only have 3 things?

Im new a scripting, im trying it out, okay?
Reply
#4

Код:
format(string,160,"* (R%d) %s: %s",PlayerInfo[playerid][pLSPD],lspdrank, params, sendername);
I highlighted the placeholders in red and the variables you wish to attach to the placeholders in cyan.

If you see, you are trying to format 4 variables into a 3 placeholder string, therefore it wouldn't work. Plus, you are making a integer variable format into a string variable (players name). I fixed it though, as it seems you added one extra thing and had the variables arranged wrongly.

I hope I explained it well enough, does it work now?
Reply
#5

Gonna test it now, thank you!

- Nope, still says the rank then the message ;/
Reply
#6

pawn Код:
GetPlayerName(playerid,sendername,sizeof(sendernam e));
Could it be because you have a space after the m? Remove the space

pawn Код:
GetPlayerName(playerid,sendername,sizeof(sendername));
Reply
#7

Couldn't be since I accidently placed the space in when typing, it doesn't have the space in on the script. ;/
Reply
#8

By the way, the thing you put in the quote box at first the line with the sendername, params, etc - It looked exactly the same as what I had before? You sure you edited it?

Thanks
Reply
#9

This?

pawn Код:
//Old line
format(string,160,"* (R%d) %s: %s",PlayerInfo[playerid][pLSPD],lspdrank, params, sendername);
//New line
format(string,160,"* (R%d) %s: %s",lspdrank, sendername, params);
See the difference? (if this is what you were talking about)
Reply
#10

FIXED, thank you so much man!!!!

It finally works!! How can I remove the _ from the name though?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)