PlayerName - usually warning
#1

Код:
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(1362) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
i make some commands and i have same warning like this before

command:

Код:
CMD:jail(playerid,params[]) {
	if (PlayerInfo[playerid][pAdmin] >= 2) {
		new id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME], string[128];
		if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jail <playerid> <time> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
		if(PlayerInfo[id][pAdmin] > PlayerInfo[playerid][pAdmin])return SendClientMessage(playerid,COLOR_RED,"ERROR: He is a greater level than your level.");
		if(Jailed[id] == 1)return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is already jailed.");
		GetPlayerName(id, PlayerName, sizeof(PlayerName));
		GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
		format(string, sizeof(string), "-X Admin-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
		SendClientMessage(playerid, COLOR_RED, string);
		format(string, sizeof(string), "Admin %s, Command Used 'JAIL' Taregt: %s (ID:%d)", GPlayerName, PlayerName, id);
		SendClientMessage(playerid, COLOR_RED, string);
		Jailed[id] = 1;
		SetPlayerInterior(id, 3);
		SetPlayerVirtualWorld(id, 10);
		SetPlayerFacingAngle(id, 360.0);
		SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
		SetPlayerHealth(id, 9999999999.0);
		ResetPlayerWeapons(id);
		JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
	}
	else {
	    return 0;
	}
	return 1;
}
Reply
#2

Try this

pawn Код:
CMD:jail(playerid,params[]) {
    if (PlayerInfo[playerid][pAdmin] >= 2) {
        new id,time,reason[100],GPlayerName[MAX_PLAYER_NAME], string[128];
        if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jail <playerid> <time> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
        if(PlayerInfo[id][pAdmin] > PlayerInfo[playerid][pAdmin])return SendClientMessage(playerid,COLOR_RED,"ERROR: He is a greater level than your level.");
        if(Jailed[id] == 1)return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is already jailed.");
        GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
        format(string, sizeof(string), "-X Admin-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName(playerid), id, time, reason);
        SendClientMessage(playerid, COLOR_RED, string);
        format(string, sizeof(string), "Admin %s, Command Used 'JAIL' Taregt: %s (ID:%d)", GPlayerName, PlayerName(playerid), id);
        SendClientMessage(playerid, COLOR_RED, string);
        Jailed[id] = 1;
        SetPlayerInterior(id, 3);
        SetPlayerVirtualWorld(id, 10);
        SetPlayerFacingAngle(id, 360.0);
        SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
        SetPlayerHealth(id, 9999999999.0);
        ResetPlayerWeapons(id);
        JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
    }
    else {
        return 0;
    }
    return 1;
Reply
#3

Код:
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(1367) : error 076: syntax error in the expression, or invalid function call
C:\Users\toni\Desktop\Gang War Los Santos 0.3e\gamemodes\mod.pwn(1367) : error 072: "sizeof" operator is invalid on "function" symbols
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
line 1367:
Код:
        GetPlayerName(id, PlayerName, sizeof(PlayerName));
Reply
#4

Code provided in 1st post is correct.
What causes error is this:
pawn Код:
new id,time,reason[100],PlayerName[MAX_PLAYERS]
.
You are trying to define already defined variable.
Just change PlayerName to for example PlayeRName and it will work

Greetz,
LetsOWN
Reply
#5

no... this is command:

Код:
CMD:jail(playerid,params[]) {
	if (PlayerInfo[playerid][pAdmin] >= 2) {
		new id,time,reason[100],PlayerName[MAX_PLAYERS],GPlayerName[MAX_PLAYERS], string[128];
		if(sscanf(params,"dds",id,time,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jail <playerid> <time> <reason>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
		if(PlayerInfo[id][pAdmin] > PlayerInfo[playerid][pAdmin])return SendClientMessage(playerid,COLOR_RED,"ERROR: He is a greater level than your level.");
		if(Jailed[id] == 1)return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is already jailed.");
		GetPlayerName(id, PlayerName, sizeof(PlayerName));
		GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
		format(string, sizeof(string), "-X Admin-: %s (ID:%d) has been jailed for %d minutes; Reason: %s", PlayerName, id, time, reason);
		SendClientMessage(playerid, COLOR_RED, string);
		format(string, sizeof(string), "Admin %s, Command Used 'JAIL' Taregt: %s (ID:%d)", GPlayerName, PlayerName, id);
		SendClientMessage(playerid, COLOR_RED, string);
		Jailed[id] = 1;
		SetPlayerInterior(id, 3);
		SetPlayerVirtualWorld(id, 10);
		SetPlayerFacingAngle(id, 360.0);
		SetPlayerPos(id, 197.5662, 175.4800, 1004.0);
		SetPlayerHealth(id, 9999999999.0);
		ResetPlayerWeapons(id);
		JailTimer[id] = SetTimerEx("Unjail",time*60000, false, "i", id);
	}
	else {
	    return 0;
	}
	return 1;
}
same warning :/
Reply
#6

Flame check my pm. or try the command i added. i i forgot to remove something. try it now
Reply
#7

Quote:
Originally Posted by pds2012
Посмотреть сообщение
Flame check my pm. or try the command i added. i i forgot to remove something. try it now
tnx man, now its without warnings [+REP
Reply
#8

No problem. unlucky you can only rep people when you got 50 pots
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)