SA-MP Forums Archive
./explode problem - 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: ./explode problem (/showthread.php?tid=569149)



./explode problem - Ritzy2K - 28.03.2015

this command works perfectly like it needs to -
pawn Код:
COMMAND:explode(playerid, params[])
{
        new bombid;
   
        if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
        if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");

        if (PlayerInfo[playerid][pAdminLevel] > 0 || IsPlayerAdmin(playerid))
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(bombid,x,y,z);
            CreateExplosion(x,y,z,6,5);
            CreateExplosion(x+2.5,y,z,6,2.5);
            CreateExplosion(x,y+2.5,z,6,2.5);
            CreateExplosion(x,y,z+2.5,6,2.5);
            SetPlayerHealth(bombid, 0.0);
            GMT(bombid, "~w~An Admin ~r~Exploded ~n~~w~You",2000,3);

        }else{
            SendClientMessage(playerid,COLOR_ERROR,"Unknown Command! Type /cmds To See All Available Commands");
        }
        return 1;
}
but the problem is...even if the client isnt an admin and types /explode it shows him the usage...i want that it should show him the error message of unknown command..i hope u got me :3


Re : ./explode problem - iFiras - 28.03.2015

pawn Код:
COMMAND:explode(playerid, params[])
{
        new bombid;
        if(!PlayerInfo[playerid][pAdminLevel] > 0 || !IsPlayerAdmin(playerid) return 0; // This shows the "unknown command" message.
        if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
        if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");

        else
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(bombid,x,y,z);
            CreateExplosion(x,y,z,6,5);
            CreateExplosion(x+2.5,y,z,6,2.5);
            CreateExplosion(x,y+2.5,z,6,2.5);
            CreateExplosion(x,y,z+2.5,6,2.5);
            SetPlayerHealth(bombid, 0.0);
            GMT(bombid, "~w~An Admin ~r~Exploded ~n~~w~You",2000,3);

        }
        return 1;
}



Re: ./explode problem - Ritzy2K - 28.03.2015

oh ty mate


Re: ./explode problem - Karan007 - 28.03.2015

Maybe it works.
Код:
COMMAND:explode(playerid, params[])
{
        new bombid;
   
        if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
        if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");

        if (!PlayerInfo[playerid][pAdminLevel] > 0 || !IsPlayerAdmin(playerid)) return 			SendClientMessage(playerid,COLOR_ERROR,"Unknown Command! Type /cmds To See All Available Commands");
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(bombid,x,y,z);
            CreateExplosion(x,y,z,6,5);
            CreateExplosion(x+2.5,y,z,6,2.5);
            CreateExplosion(x,y+2.5,z,6,2.5);
            CreateExplosion(x,y,z+2.5,6,2.5);
            SetPlayerHealth(bombid, 0.0);
			GMT(bombid, "~w~An Admin ~r~Exploded ~n~~w~You",2000,3);
        return 1;
}



Re: ./explode problem - Loot - 28.03.2015

That's because you're checking if the player is an admin AFTER showing him how to use this command...
Код:
COMMAND:explode(playerid, params[])
{
        if (PlayerInfo[playerid][pAdminLevel] > 0 || IsPlayerAdmin(playerid)) //if the player is an admin/logged as RCON let him use this command
        {
                new bombid;
                if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
                if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");

                new Float:x,Float:y,Float:z;
                GetPlayerPos(bombid,x,y,z);
                CreateExplosion(x,y,z,6,5);
                CreateExplosion(x+2.5,y,z,6,2.5);
                CreateExplosion(x,y+2.5,z,6,2.5);
                CreateExplosion(x,y,z+2.5,6,2.5);
                SetPlayerHealth(bombid, 0.0);
                GMT(bombid, "~w~An Admin ~r~Exploded ~n~~w~You",2000,3);
        }
        else return SendClientMessage(playerid,COLOR_ERROR,"Unknown Command! Type /cmds To See All Available Commands"); // if not - show him an error message
        return 1;
}