[HELP] Problem /stats
#1

Hey, i'm reciving the following errors:

Код:
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_utils.inc(343) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_utils.inc(497) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_utils.inc(540) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_utils.inc(558) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_malloc.inc(216) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\samp037_svr_R2-1-1_win32\pawno\include\YSI\y_hooks/impl.inc(1983) : warning 219: local variable "password" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(54) : error 010: invalid function or declaration
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(63) : error 021: symbol already defined: "format"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(65) : error 010: invalid function or declaration
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(69) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(275) : warning 219: local variable "password" shadows a variable at a preceding level
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "admin"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "deaths"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "kills"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "money"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "password"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "score"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(356) : warning 203: symbol is never used: "string"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.

---------------------------------------------------------------------------------------------------------------------------------
Coded script :

Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
	pScore
}

new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}


if (strcmp("/stats" cmdtext, true, 10) == 0)
{
	new password = PlayerInfo[playerid][pPass];
	new money = PlayerInfo[playerid][pCash];
	new deaths = PlayerInfo[playerid][pDeaths];
	new kills = PlayerInfo[playerid][pKills];
	new score = PlayerInfo[playerid][pScore];
	new admin = PlayerInfo[playerid][pAdmin];
	new string[500];
	format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",password,money,deaths,kills,score,admin);
	SendClientMessage(playerid,COLOR_GREEN,string);
    return 1;
}
Reply
#2

I several advice you to use ZCMD, in order to forget about strcmp.


Код:
if(!strcmp(cmdtext, "/mystats", true))
{
	new password = PlayerInfo[playerid][pPass];
	new money = PlayerInfo[playerid][pCash];
	new deaths = PlayerInfo[playerid][pDeaths];
	new kills = PlayerInfo[playerid][pKills];
	new score = PlayerInfo[playerid][pScore];
	new admin = PlayerInfo[playerid][pAdmin];
	new string[500];
	format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",password,money,deaths,kills,score,admin);
	SendClientMessage(playerid,COLOR_GREEN,string);
    return 1;
}
Advice me for any other error found.

Regards.
Reply
#3

Yeah, i'v found another problem or the same one...

Quote:

C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(54) : error 010: invalid function or declaration
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(63) : error 021: symbol already defined: "format"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(65) : error 010: invalid function or declaration

Line 63,54,65:
Quote:

format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",password,money,deaths,kills,score,admin);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;

Код:
if(!strcmp(cmdtext, "/mystats", true))
Reply
#4

double post.
Reply
#5

Quote:
Originally Posted by xEF
Посмотреть сообщение
Variables definition, put them out of the command.
Can you be more specific?
Reply
#6

Код:
if(!strcmp(cmdtext, "/mystats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}
Reply
#7

I used you're code and i have another error:
Quote:

C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(53) : error 010: invalid function or declaration
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(56) : error 021: symbol already defined: "format"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(5 : error 010: invalid function or declaration

Code:

Quote:

if(!strcmp(cmdtext, "/stats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}

Reply
#8

Did you add the command into onplayercommandtext?
Reply
#9

Like this?

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/stats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;

Reply
#10

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/mystats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
        // Returning 1 informs the server that the command has been processed.
        // OnPlayerCommandText won't be called in other scripts.
}
    return 0;
    // Returning 0 informs the server that the command hasn't been processed by this script.
    // OnPlayerCommandText will be called in other scripts until one returns 1.
    // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
}
Reply
#11

Thanks, the problem is solved but now there's another one.
Quote:

C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(59) : error 017: undefined symbol "COLOR_GREEN"
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(167) : error 021: symbol already defined: "S@@_OnPlayerCommandText"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

I think that the problem is that i always used OnCommandText twice and i cant do it, i simply dont know, any suggestion?
Reply
#12

#define COLOR_GREEN 0x00FF00AA
Reply
#13

Quote:
Originally Posted by xEF
View Post
#define COLOR_GREEN 0x00FF00AA
Yeah, i'v already fixed that i defined color_red and not color_green, anyways that's not the problem anymore.
Code:
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(59) : error 035: argument type mismatch (argument 2)
C:\Users\Nelson.Paulo2301-PC\Desktop\LoginRegister.pwn(167) : error 021: symbol already defined: "S@@_OnPlayerCommandText"
Code:
Line 59 - 
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/mystats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COL_GREEN,string);
        return 1;
        // Returning 1 informs the server that the command has been processed.
        // OnPlayerCommandText won't be called in other scripts.
    }
    return 0;
    // Returning 0 informs the server that the command hasn't been processed by this script.
    // OnPlayerCommandText will be called in other scripts until one returns 1.
    // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
Code:
Line 167 - 
public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/rules", cmdtext, true, 10) == 0)
        {
                 SendClientMessage(playerid, 0x33CC00, "1. Cheating and hacking leads to a permenant ban.");
  SendClientMessage(playerid, 0x33CC00, "Do not insult players or get punished.");
   SendClientMessage(playerid, 0x33CC00, "Do not flood that chat or advertise other servers.");
    SendClientMessage(playerid, 0x33CC00, "Do not report players in the main chat.");
    SendClientMessage(playerid, 0x33CC00, "Do not quit or pause to avoid anything.");
    SendClientMessage(playerid, 0x33CC00, "Do not exploit bugs instantly report them.");
 SendClientMessage(playerid, 0x33CC00, "Do not share you're account with anyone.");
                return 1;
        }
        return 0;
}
Reply
#14

Maybe you have double 'onplayercommandtext'
Reply
#15

Quote:
Originally Posted by xEF
View Post
Maybe you have double 'onplayercommandtext'
Yeah, i'v removed one and it worked, now i'm having another problem.

error 035: argument type mismatch (argument 2)

Line: SendClientMessage(playerid,COL_GREEN,string);

Full Code :
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/mystats", true))
{
new string[500];
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,COL_GREEN,string);
        return 1;
        // Returning 1 informs the server that the command has been processed.
        // OnPlayerCommandText won't be called in other scripts.
    }
    return 0;
    // Returning 0 informs the server that the command hasn't been processed by this script.
    // OnPlayerCommandText will be called in other scripts until one returns 1.
    // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
}
Reply
#16

Bump, really need this problem resolved as fast as possible..
Reply
#17

Code:
SendClientMessage(playerid,COLOR_GREEN,string);
Reply
#18

Quote:
Originally Posted by xEF
View Post
Code:
SendClientMessage(playerid,COLOR_GREEN,string);
I dont understand it, the code is still the same and well built....
Even if i do use COLOR_GREEN or COL_GREEN define, it's the same error....
Reply
#19

I tried to define the color_green and col_green, none of them worked, i really need to resolve this problem, any suggestion?
Reply
#20

Add your define on top of your gamemode.
Below the includes, out of any public or stock.

Regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)