PDA

View Full Version : problem with format


Lirbo
17/04/2014, 09:55 PM
This in the public
public OnPlayerText(playerid, text[])
{
new Text[144];
format(String,sizeof(String),"%s says: %s",NickName,Text);
SendClientMessage(playerid,-1,String);
return 1;
}

This is the error line
format(String,sizeof(String),"%s says: %s",NickName,Text);

This is the error:
error 076: syntax error in the expression, or invalid function call

This is the stock of 'NickName':
stock NickName(playerid)
{
new nick[MAX_STRING];
GetPlayerName(playerid, nick, sizeof(nick));
nick = strreplace("_", " ", nick);
return nick;
}

mrkiller90
17/04/2014, 09:56 PM
new String[128];

Brandon_More
17/04/2014, 09:57 PM
format(String,sizeof(String),"%s says: %s",NickName(playerid),text);



public OnPlayerText(playerid, text[])
{
new String[144];
format(String,sizeof(String),"%s says: %s",NickName(playerid),text);
SendClientMessage(playerid,-1,String);
return 1;
}

Firewire
17/04/2014, 09:57 PM
public OnPlayerText(playerid, text[])
{
new Text[144]; // Also make a new string if that's not been defined elsewhere in the script.

format(String,sizeof(String),"%s says: %s",NickName(playerid),Text);
SendClientMessage(playerid,-1,String);
return 1;
}


That will fix it, you forgot to add (Playerid) onto the end of your NickName function.

All the best,
Firewire.

EDIT: Wow, we all posted at the same time.

Lirbo
17/04/2014, 11:00 PM
Thanks guys :) resolved... i had to add (playerid) after NickName