SA-MP Forums Archive
Compile Error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Compile Error (/showthread.php?tid=559597)



Compile Error - SecretBoss - 24.01.2015

My command

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/dm", cmdtext, true, 4) == 0)
    {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        if(InDM[playerid] == 0)
        {
            InDM[playerid] = 1;
            SendClientMessage(playerid, COLOR_LIGHTBLUE , "You have joined /dm, to leave type /dm again");
            format(String, sizeof(String), "Server:{FFFFFF}%s(%d) has joined DM(/dm)", PlayerName, playerid);
            SendClientMessageToAll(COLOR_LIGHTBLUE, String);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 10);
            new rand = random(sizeof(DMSpawns));
            SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);
            SetPlayerFacingAngle(playerid, DMSpawns[rand][3]);
            GivePlayerWeapon(playerid, 24, 1500);
            GivePlayerWeapon(playerid, 26, 1500);
        }
        else {
            InDM[playerid] = 0;
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have left /dm to join again type /dm");
            SpawnPlayer(playerid);
            SetPlayerHealth(playerid, 100);
            ResetPlayerWeapons(playerid);
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerInterior(playerid, 0);
        }
        return 1;
        }
    return 0;
}
My compile error

pawn Код:
gamemodes\ngcgm.pwn(2393) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
Any idea on how to fix it?


Re: Compile Error - Youssef221 - 24.01.2015

Change PlayerName to anything else like pname


Re: Compile Error - SecretBoss - 24.01.2015

Alrady tried and I got that error

pawn Код:
(2394) : error 076: syntax error in the expression, or invalid function call
(2394) : error 072: "sizeof" operator is invalid on "function" symbols
(2399) : error 076: syntax error in the expression, or invalid function call
(2393) : warning 204: symbol is assigned a value that is never used: "pName"



Re: Compile Error - ReshiramZekrom - 24.01.2015

Try in this way:


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/dm", cmdtext, true, 4) == 0)
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        if(InDM[playerid] == 0)
        {
            InDM[playerid] = 1;
            SendClientMessage(playerid, COLOR_LIGHTBLUE , "You have joined /dm, to leave type /dm again");
            format(String, sizeof(String), "Server:{FFFFFF}%s(%d) has joined DM(/dm)", pName, playerid);
            SendClientMessageToAll(COLOR_LIGHTBLUE, String);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 10);
            new rand = random(sizeof(DMSpawns));
            SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);
            SetPlayerFacingAngle(playerid, DMSpawns[rand][3]);
            GivePlayerWeapon(playerid, 24, 1500);
            GivePlayerWeapon(playerid, 26, 1500);
        }
        else {
            InDM[playerid] = 0;
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have left /dm to join again type /dm");
            SpawnPlayer(playerid);
            SetPlayerHealth(playerid, 100);
            ResetPlayerWeapons(playerid);
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerInterior(playerid, 0);
        }
        return 1;
        }
    return 0;
}



Re: Compile Error - SecretBoss - 24.01.2015

Yeah its worked thanks for helping +REP