Problem with my OnPlayerText
#1

Hi. I just added my new OnPlayerText, and this is what it said in the chat when i type Hi: "Hi".
This is not a problem, but how i want it is: "[Local IC]: Hi''. I know it is an easy and simple thing, but
You would do me a big favour if you would help me. I tried to edit it, but i fail in those kinds of things.
Here's the code.

Код:
public OnPlayerText(playerid, text[])
{
    new name[20];
    GetPlayerName(playerid,name,20);
    format(text,sizeof(text),"%s[ID:%d] : %s",name,playerid,text);
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    for(new i = 0;i<MAX_PLAYERS;++i)
    {
        if(IsPlayerInRangeOfPoint(i,5,X,Y,Z)) SendClientMessage(i,-1,text);
        return 0;
    }
    return 1;
}
Reply
#2

You mean like this?
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        name[MAX_PLAYER_NAME],
        string[128],
        Float:X,
        Float:Y,
        Float:Z;

    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, X, Y, Z);
   
    format(string, sizeof(string), "[Local IC] %s (%d) : %s", name, playerid, text[0]);

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, string);
    }

    return 0;
}
Reply
#3

Too bad...

Код:
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.0.pwn(684) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.0.pwn(692) : error 017: undefined symbol "string"
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.0.pwn(692) : error 017: undefined symbol "string"
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.0.pwn(692) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.0.pwn(692) : fatal error 107: too many error messages on one line
Reply
#4



Sorry, look again.
Reply
#5

Код:
warning 219: local variable "str" shadows a variable at a preceding level
there is already new str or global str somewhere delete it.

Код:
error 017: undefined symbol "string"
you have just copy this part are not you?

pawn Код:
GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, X, Y, Z);
   
    format(string, sizeof(string), "[Local IC] %s (%d) : %s", name, playerid, text[0]);

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, string);
    }
change the following to fix the problem, You must make global str with size of 128 to make this work.

change this

pawn Код:
format(string, sizeof(string), "[Local IC] %s (%d) : %s", name, playerid, text[0]);
to this

pawn Код:
format(str, sizeof(str), "[Local IC] %s (%d) : %s", name, playerid, text[0]);
change this

pawn Код:
if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, string);
to this

pawn Код:
if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, str);
if global str with size of 128 or whatever is already created or made you don't need to create a new one with the same size and name.
Reply
#6

Quote:
Originally Posted by Romel
Посмотреть сообщение
Код:
warning 219: local variable "str" shadows a variable at a preceding level
there is already new str or global str somewhere delete it.

Код:
error 017: undefined symbol "string"
you have just copy this part are not you?

pawn Код:
GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, X, Y, Z);
   
    format(string, sizeof(string), "[Local IC] %s (%d) : %s", name, playerid, text[0]);

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, string);
    }
change the following to fix the problem, You must make global str with size of 128 to make this work.

change this

pawn Код:
format(string, sizeof(string), "[Local IC] %s (%d) : %s", name, playerid, text[0]);
to this

pawn Код:
format(str, sizeof(str), "[Local IC] %s (%d) : %s", name, playerid, text[0]);
change this

pawn Код:
if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, string);
to this

pawn Код:
if(IsPlayerInRangeOfPoint(i, 5, X, Y, Z)) SendClientMessage(i, -1, str);
if global str with size of 128 or whatever is already created or made you don't need to create a new one with the same size and name.
That was actually my fault. I forgot to change "str" to "string" at the start.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)