Errors and Warnings doing the local chat system
#1

Hi guys.

So I tried to do a local chat system for my gamemode by myself, using foreach and zcmd, as some users advice me earlier, but it as some warnings and errors that I don't know how to fix.
The code:

PHP код:
public OnPlayerText;
new 
string[144], text[120], name[MAX_PLAYER_NAME], FloatpXFloatpYFloatpZ;
GetPlayerName (playeridnamesizeof(name));
  
format(string1sizeof(string1), "%s diz: %s"nametext); // "diz" = " says " in english
    
GetPlayerPos(playeridposXposYposZ);
     foreach(new 
iPlayer)
    {
        if(
IsPlayerInRangeOfPoint(i6.0pXpYpZ))
        {
            
SendClientMessage(ibrancostring); //"branco" = " white " in english 
        
}
    } 
And there's the warnings and the errors:

Quote:

C:\Users\Joka\Desktop\New folder (2)\pawno\include\sscanf2.inc(199) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\pawno\include\sscanf2.inc(305) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\pawno\include\sscanf2.inc(305) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\pawno\include\sscanf2.inc(365) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\pawno\include\sscanf2.inc(365) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "text" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "pX" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "pY" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(33) : warning 219: local variable "pZ" shadows a variable at a preceding level
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(55) : error 021: symbol already defined: "GetPlayerName"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(5 : error 010: invalid function or declaration
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(60) : error 010: invalid function or declaration
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "name"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "pX"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "pY"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "pZ"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "string"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(66) : warning 203: symbol is never used: "text"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

Reply
#2

Bump
Reply
#3

Can anyone help ?
Reply
#4

I change the code and some errors were fixed, I'm kinda of noob xD, the string was already created so there wasn't need of creating a new one, but still got three errors, (but no warnings)

The new code is:

Quote:

public OnPlayerText;

GetPlayerName(playerid, name, sizeof(name)
format(string, sizeof(string), "%s diz: %s", name, text);
GetPlayerPos(playerid, posX, posY, posZ);
foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
{
SendClientMessage(i, branco, string);
}
}

The errors:

Quote:

C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(54) : error 021: symbol already defined: "GetPlayerName"
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(57) : error 010: invalid function or declaration
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(59) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

Apreciate any help
Reply
#5

pawn Код:
public OnPlayerText(playerid, text[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof name);
    format(string, sizeof(string), "%s diz: %s", name, text);
    new Float: pX, Float: pY, Float: pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    foreach(new i: Player)
    {
        if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ)) {
            SendClientMessage(i, branco , string), return 0;
        }
    }
    return 1;
}
Reply
#6

Thank you O_x your code helped, as I'm newbie I still don't understand very good the " return ", so now I change a little bit your code to create the strings I needed, and i just got 1 error, didn't understand what is

Code:

Quote:

public OnPlayerText(playerid, text[])
{

new name[MAX_PLAYER_NAME], string[144], Float: pX, Float: pY, Float: pZ;
GetPlayerName(playerid, name, sizeof name);
format(string, sizeof(string), "%s diz: %s", name, text);
GetPlayerPos(playerid, pX, pY, pZ);
foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ)) {
SendClientMessage(i, branco , string), return 0;
}
}
return 1;
}

Error:

Quote:

C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(62) : error 029: invalid expression, assumed zero
C:\Users\Joka\Desktop\New folder (2)\gamemodes\GamemodeRP.pwn(62) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

PS: It isn't the expression " branco " cuz I have in top of the game mode " #define branco 0xFFFFFFAA "
Reply
#7

pawn Код:
public OnPlayerText(playerid, text[])
{
    new name[MAX_PLAYER_NAME], string[144], Float: pX, Float: pY, Float: pZ;
    GetPlayerName(playerid, name, sizeof name);
    format(string, sizeof(string), "%s diz: %s", name, text);
    GetPlayerPos(playerid, pX, pY, pZ);
    foreach(new i: Player)
    {
        if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
        {
            SendClientMessage(i, branco, string);
        }  
    }
    return 1;
}
Reply
#8

Well I fixed it, it was return that was in the bad position

Quote:

public OnPlayerText(playerid, text[])
{

new name[MAX_PLAYER_NAME], string[144], Float: pX, Float: pY, Float: pZ;
GetPlayerName(playerid, name, sizeof name);
format(string, sizeof(string), "%s diz: %s", name, text);
GetPlayerPos(playerid, pX, pY, pZ);
foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, 6.0, pX, pY, pZ))
{
SendClientMessage(i, branco , string);

}
return 0;
}
return 1;

New code, and It's working thanks a lot for the help O_x
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)