SA-MP Forums Archive
help cmd - 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: help cmd (/showthread.php?tid=657587)



help cmd - nbx2000 - 11.08.2018

hello I need help to put this cmd only for administrator but I will try it and not all the players can use it, you can help me for only admin cmd and qe say if you are not an administrator you do not have administrator level
Код:
CMD:placegate( playerid, params[] )
{
        if(PlayerInfo[playerid][Level] >= 4)
        if( isnull( params) )
            return SendClientMessage( playerid, -1, "Syntax: /placegate [password]" );

        if( !strval( params ) )
            return SendClientMessage( playerid, -1, "You need to input numbers." );

        if( IsPlayerInAnyVehicle( playerid ) )
            return SendClientMessage( playerid, -1, "You need to exit your vehicle." );

        new Float:pPos[4];
        GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
        GetPlayerFacingAngle( playerid, pPos[3] );
        CreateGate( playerid, strval( params ), pPos[0], pPos[1], pPos[2], pPos[3] );
        SendClientMessage( playerid, -1, "You succesfully created a movable gate. Use /gopen or /gclose." );

        return 1;
}



Re: help cmd - Mike861 - 11.08.2018

Код:
if(PlayerInfo[playerid][Level] >=4)
{
   Whole cmd code inside here..
}
else SendClientMessage(playerid,color,"You're not admin.");



Re: help cmd - nbx2000 - 11.08.2018

Quote:
Originally Posted by Mike861
Посмотреть сообщение
Код:
if(PlayerInfo[playerid][Level] >=4)
{
   Whole cmd code inside here..
}
else SendClientMessage(playerid,color,"You're not admin.");
error


CMDlacegate( playerid, params[] )
{
if(PlayerInfo[playerid][Level] >= 4)
if( isnull( params) )
return SendClientMessage( playerid, -1, "Syntax: /placegate [password]" );

if( !strval( params ) )
return SendClientMessage( playerid, -1, "You need to input numbers." );

if( IsPlayerInAnyVehicle( playerid ) )
return SendClientMessage( playerid, -1, "You need to exit your vehicle." );

new FloatPos[4];
GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
GetPlayerFacingAngle( playerid, pPos[3] );
CreateGate( playerid, strval( params ), pPos[0], pPos[1], pPos[2], pPos[3] );
SendClientMessage( playerid, -1, "You succesfully created a movable gate. Use /gopen or /gclose." );
return 1;
else SendClientMessage(playerid,red,"You're not admin.");
}

pwn(36167) : warning 225: unreachable code
error 029: invalid expression, assumed zero
(3616 : warning 209: function "cmd_placegate" should return a value


Re: help cmd - Variable™ - 11.08.2018

Код:
CMD:placegate( playerid, params[] )
{
    if(PlayerInfo[playerid][Level] >= 4)
    {
        if( isnull( params) )
            return SendClientMessage( playerid, -1, "Syntax: /placegate [password]" );

        if( !strval( params ) )
            return SendClientMessage( playerid, -1, "You need to input numbers." );

        if( IsPlayerInAnyVehicle( playerid ) )
            return SendClientMessage( playerid, -1, "You need to exit your vehicle." );

        new Float:pPos[4];
        GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
        GetPlayerFacingAngle( playerid, pPos[3] );
        CreateGate( playerid, strval( params ), pPos[0], pPos[1], pPos[2], pPos[3] );
        SendClientMessage( playerid, -1, "You succesfully created a movable gate. Use /gopen or /gclose." );
    }
    return 1;
}



Re: help cmd - CaptainBoi - 11.08.2018

PHP код:
CMD:placegate(playeridparams[])
{
        if(
PlayerInfo[playerid][Level] >= 4) return SendClientMessage(playerid, -1"You are not admin");
        if(
isnull(params)) return SendClientMessage(playerid, -1"Syntax: /placegate [password]");
        if(!
strval(params)) return SendClientMessage(playerid, -1"You need to input numbers.");
        if(
IsPlayerInAnyVehicle(playerid )) return SendClientMessage(playerid, -1"You need to exit your vehicle.");
        new 
Float:pPos[4];
        
GetPlayerPos(playeridpPos[0], pPos[1], pPos[2]);
        
GetPlayerFacingAngle(playeridpPos[3]);
        
CreateGate(playeridstrval(params), pPos[0], pPos[1], pPos[2], pPos[3]);
        
SendClientMessage(playerid, -1"You succesfully created a movable gate. Use /gopen or /gclose.");
        return 
1;

try this


Re: help cmd - Sew_Sumi - 11.08.2018

Check if they can run the command first, like what CaptainBoi chucked up.

Check simple, broad shit first, then do your more detailed checks.


Re: help cmd - Mike861 - 11.08.2018

Код:
if(PlayerInfo[playerid][Level] >= 4) return SendClientMessage(playerid, -1, "You are not admin");
You basically did the opposite from what he wanted to do.Now if the player is higher level than 4 or the level 4 he cannot use this command but only admins with level below can.


Re: help cmd - nbx2000 - 12.08.2018

I tried it without admin level and it can be any player does not walk


Re: help cmd - AlexMSK - 12.08.2018

Код:
CMD:placegate( playerid, params[] )
{
        if(PlayerInfo[playerid][Level] < 4) return SendClientMessage(playerid, -1, "You are not authorized to use this command");
        if( isnull( params) )
            return SendClientMessage( playerid, -1, "Syntax: /placegate [password]" );

        if( !strval( params ) )
            return SendClientMessage( playerid, -1, "You need to input numbers." );

        if( IsPlayerInAnyVehicle( playerid ) )
            return SendClientMessage( playerid, -1, "You need to exit your vehicle." );

        new Float:pPos[4];
        GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
        GetPlayerFacingAngle( playerid, pPos[3] );
        CreateGate( playerid, strval( params ), pPos[0], pPos[1], pPos[2], pPos[3] );
        SendClientMessage( playerid, -1, "You succesfully created a movable gate. Use /gopen or /gclose." );

        return 1;
}