SA-MP Forums Archive
Admin duty script. - 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: Admin duty script. (/showthread.php?tid=349251)



Admin duty script. - Misterflowers - 08.06.2012

Hey, I need admin duty script please.
/aduty and /aoffduty when you doing the command it's change your name to Green or something like that.


Re: Admin duty script. - lewismichaelbbc - 08.06.2012

Код:
if(strcmp(cmd, "/aduty", true) == 0)
{
    if(IsPlayerAdmin(playerid))
    {
        SetPlayerColor(giveplayerid, 0x00CA0000);
        return 1;
    }
}



Re: Admin duty script. - Jarnu - 08.06.2012

pawn Код:
CMD:aduty(playerid, params[])
{
SetPlayerColor(playerid, Your Color);
SetPlayerHealth(playerid, 100000);
SendClientMessage(playerid, Your Color,"You are Now on Admin Duty!");
return 1;
}
if need more advance.. then tell.


Re: Admin duty script. - FalconX - 08.06.2012

Quote:
Originally Posted by Misterflowers
Посмотреть сообщение
Hey, I need admin duty script please.
/aduty and /aoffduty when you doing the command it's change your name to Green or something like that.
Not tested but I think this is what you want:-

pawn Код:
new bool:fCheckDutyStatus[ MAX_PLAYERS ]; // top

fCheckDutyStatus[ playerid ] = false; // OnPlayerConnect and OnPlayerDIsconnect

CMD:aduty( playerid, params[ ] )
{
    if( IsPlayerAdmin( playerid ) ) // if the player is admin, you can change this var to your own admin system
    {
        if( fCheckDutyStatus[ playerid ] ) // if he is on duty, he will be NOT in duty
        {
            fCheckDutyStatus[ playerid ] = false;
            SendClientMessage( playerid, -1, "SERVER: You are NOT in the duty." );
        }
        else // if he is not on duty, he gets on duty
        {
            fCheckDutyStatus[ playerid ] = true;
            SendClientMessage( playerid, -1, "SERVER: You are now in duty" );
        }
    }
    else // he is not admin
    {
        SendClientMessage( playerid, -1, "ERROR: you are not an admin." );
    }
    return 1;
}

CMD:adutycheck( playerid, params[ ] )
{
    new fCountDutyPlayers = 0, Fstring[ 35 ]; // new declared strings
    for( new f = 0; f < MAX_PLAYERS; f++ ) // looping to check who is on duty
    {
        if( IsPlayerConnected( f ) )
        {
            if( fCheckDutyStatus[ f ] ) // players those who have duty on status
            {
                fCountDutyPlayers++;
                if( fCountDutyPlayers == 0 ) return SendClientMessage( playerid, -1, "There is NO ONE on duty." );
                format( Fstring, sizeof( Fstring ), "Player %s is ON duty", fPlayerName( f ) );
                SendClientMessage( playerid, -1, Fstring );
            }
        }
    }
    format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyStatus );
    SendClientMessage( playerid, -1, Fstring );
    return 1;
}

stock fPlayerName( playerid ) // stock for getting player names
{
    new FpName[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, FpName, sizeof( FpName ) );
    return FpName;
}
Hope this helps, note that it is not tested.
-FalconX


Re: Admin duty script. - Misterflowers - 08.06.2012

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Not tested but I think this is what you want:-

pawn Код:
new bool:fCheckDutyStatus[ MAX_PLAYERS ]; // top

fCheckDutyStatus[ playerid ] = false; // OnPlayerConnect and OnPlayerDIsconnect

CMD:aduty( playerid, params[ ] )
{
    if( IsPlayerAdmin( playerid ) ) // if the player is admin, you can change this var to your own admin system
    {
        if( fCheckDutyStatus[ playerid ] ) // if he is on duty, he will be NOT in duty
        {
            fCheckDutyStatus[ playerid ] = false;
            SendClientMessage( playerid, -1, "SERVER: You are NOT in the duty." );
        }
        else // if he is not on duty, he gets on duty
        {
            fCheckDutyStatus[ playerid ] = true;
            SendClientMessage( playerid, -1, "SERVER: You are now in duty" );
        }
    }
    else // he is not admin
    {
        SendClientMessage( playerid, -1, "ERROR: you are not an admin." );
    }
    return 1;
}

CMD:adutycheck( playerid, params[ ] )
{
    new fCountDutyPlayers = 0, Fstring[ 35 ]; // new declared strings
    for( new f = 0; f < MAX_PLAYERS; f++ ) // looping to check who is on duty
    {
        if( IsPlayerConnected( f ) )
        {
            if( fCheckDutyStatus[ f ] ) // players those who have duty on status
            {
                fCountDutyPlayers++;
                if( fCountDutyPlayers == 0 ) return SendClientMessage( playerid, -1, "There is NO ONE on duty." );
                format( Fstring, sizeof( Fstring ), "Player %s is ON duty", fPlayerName( f ) );
                SendClientMessage( playerid, -1, Fstring );
            }
        }
    }
    format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyStatus );
    SendClientMessage( playerid, -1, Fstring );
    return 1;
}

stock fPlayerName( playerid ) // stock for getting player names
{
    new FpName[ MAX_PLAYER_NAME ];
    GetPlayerName( playerid, FpName, sizeof( FpName ) );
    return FpName;
}
Hope this helps, note that it is not tested.
-FalconX
(66441) : error 010: invalid function or declaration
(66481) : error 017: undefined symbol "fCountDutyStatus"


Re: Admin duty script. - FalconX - 08.06.2012

Quote:
Originally Posted by Misterflowers
Посмотреть сообщение
(66441) : error 010: invalid function or declaration
(66481) : error 017: undefined symbol "fCountDutyStatus"
Umm, sorry just replace this:-

pawn Код:
format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyStatus );
with

pawn Код:
format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyPlayers );



Re: Admin duty script. - Misterflowers - 08.06.2012

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Umm, sorry just replace this:-

pawn Код:
format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyStatus );
with

pawn Код:
format( Fstring, sizeof( Fstring ), "Players on duty: %d", fCountDutyPlayers );
Thanks, but I got more one error.

error 010: invalid function or declaration


Re: Admin duty script. - FalconX - 08.06.2012

Quote:
Originally Posted by Misterflowers
Посмотреть сообщение
Thanks, but I got more one error.

error 010: invalid function or declaration
Line?


Re: Admin duty script. - Misterflowers - 08.06.2012

Help?


Re: Admin duty script. - Faisal_khan - 09.06.2012

Dude he meant just copy this line and paste it in your OnPlayerConnect and OnPlayerDisconnect :
pawn Код:
fCheckDutyStatus[ playerid ] = false;
Don't delete your OnPlayerConnect and OnPlayerDisconnect contents which you had earlier.