SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 14/06/2012, 09:18 PM   #1
Audi_Quattrix
Big Clucker
 
Join Date: Jul 2011
Location: Latvia
Posts: 142
Reputation: 4
Default [ZCMD] How to make Admin duty command.

Open your Gamemode

On top of Gamemode add:

pawn Code:
#define COLOR_DRED 0xFF0000AA //defines red color
new aDuty[MAX_PLAYERS];

Under OnPlayerConnect add:
pawn Code:
aDuty[playerid] = 0; //Set player off duty when connects

Under OnPlayerDisconnect add:
pawn Code:
aDuty[playerid] = 0; //set player off duty when disconnects

Add this where you place your commands in gamemode:

pawn Code:
CMD:aduty(playerid) //Doesnt need params function
{
    if(PlayerInfo[playerid][pAdmin] >=1 || IsPlayerAdmin(playerid)) //If you use rcon admin delete (PlayerInfo[playerid][pAdmin] >=1 ||
    {
        if (aDuty[playerid] == 0) //Check if player is on duty
        {
            new string[128];
            new Float:x,Float:y,Float:z;
            new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_DRED,x,y,z, 40.0, 0, 0); //Creates 3d text label at player position
            GetPlayerPos(playerid,x,y,z); //Looks for players position
            SetPlayerHealth(playerid,999999); //makes player godmode
            SetPlayerColor(playerid,COLOR_DRED); //set admin colour red
            SetPlayerSkin(playerid,294); //set admin skin to 294
            format(string,sizeof(string), "%s is now on Duty!",GetPlayerNameEx(playerid)); //here you format string to send to players
            SendClientMessageToAll(COLOR_DRED,string); //send string to players
            SendClientMessage(playerid,COLOR_DRED,"You are now on duty!"); //Tell admin he is now on duty
            Attach3DTextLabelToPlayer(label,playerid,0.0, 0.0, 0.7); //attach 3d text label made before to player
            aDuty[playerid] = 1; //Set player on duty
        }
        else if (aDuty[playerid] == 1) //Check if player is on duty
        {
            new string[128];
            new Float:x,Float:y,Float:z;
            new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_DRED,x,y,z, 40.0, 0, 0);
            Delete3DTextLabel(label); //Delete 3d text label saying "Admin On Duty!"
            SetPlayerHealth(playerid,100); //sets player health back to 100
            format(string,sizeof(string)," %s is now off Duty!",GetPlayerNameEx(playerid)); //Format string to send to players
            SendClientMessageToAll(COLOR_DRED,string); //send players string
            SendClientMessage(playerid, COLOR_DRED,"You are now off duty!"); //send admin message he is off duty
            aDuty[playerid] = 0; //sets admin off duty
        }
    }
    else
        SendClientMessage(playerid,COLOR_DRED,"You are not high level enough!"); //Error message to send to players who arent admins
    return 1;
}

EDIT:
Probably you will need this too
Add it somewhere
pawn Code:
stock GetPlayerNameEx(playerid) //This is stock i made to make Getting players name easier
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    return Name;
}
__________________






Audi_Quattrix is offline   Reply With Quote
Old 14/06/2012, 09:22 PM   #2
Revo
Huge Clucker
 
Revo's Avatar
 
Join Date: Apr 2012
Location: The Netherlands
Posts: 261
Reputation: 80
Default Re: [ZCMD] How to make Admin duty command.

This isn't much of a tutorial, had I been a complete new scriptor I wouldn't have a single clue what 99% of your code does as nothing gets explained.

"Add this, this and this and you're done!"
__________________
(09:03:52) <+Redirect_Left> i am sat in just my boxers
(09:03:52) <+Redirect_Left> tbh.
(09:03:52) <Blake> cute
Revo is offline   Reply With Quote
Old 14/06/2012, 09:25 PM   #3
Djole1337
Gangsta
 
Djole1337's Avatar
 
Join Date: Apr 2012
Location: Santa Monica, CA
Posts: 820
Reputation: 218
Default Re: [ZCMD] How to make Admin duty command.

Ugh...You just pasted code... Almost nothing explained.

Everyone knows that SetPlayerHealth(playerid,999999); makes you invincible...
Djole1337 is offline   Reply With Quote
Old 14/06/2012, 09:27 PM   #4
Jonny5
Gangsta
 
Join Date: Mar 2012
Location: Mi, USA
Posts: 935
Reputation: 146
Default Re: [ZCMD] How to make Admin duty command.

well you dont explain much its put this here and this here.....
a tutorial is meant to tutor someone,
think back to school, does a tutor do your work for you or
teach you what you need to know to complete your work on your own?

and as this is a newbie subject you should really try to avoid using custom functions such as
GetPlayerNameEx without providing them also.

i think a few small edits and you could turn this into a useful tutorial for someone looking to LEARN this.
__________________
If your topic says "REP+", I ignore it.

If you haven't tried it I suggest you do so.
Pawn PlayGround By Slice!
Jonny5 is offline   Reply With Quote
Old 14/06/2012, 09:32 PM   #5
Revo
Huge Clucker
 
Revo's Avatar
 
Join Date: Apr 2012
Location: The Netherlands
Posts: 261
Reputation: 80
Default Re: [ZCMD] How to make Admin duty command.

Quote:
EDIT:
Probably you will need this too
Add it somewhere
Are we being serious here?

Made me lol..
__________________
(09:03:52) <+Redirect_Left> i am sat in just my boxers
(09:03:52) <+Redirect_Left> tbh.
(09:03:52) <Blake> cute
Revo is offline   Reply With Quote
Old 03/12/2012, 08:25 PM   #6
dino_d_carter
Big Clucker
 
Join Date: Aug 2011
Location: Sweden, Serbia
Posts: 178
Reputation: 9
Default Re: [ZCMD] How to make Admin duty command.

Well done ) +rep
__________________
dino_d_carter is offline   Reply With Quote
Old 04/12/2012, 04:46 AM   #7
showarn
Big Clucker
 
Join Date: Aug 2010
Location: sweden
Posts: 152
Reputation: -8
Default Re: [ZCMD] How to make Admin duty command.

the script is kinda bugged with the
Quote:
new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_DRED,x,y,z, 40.0, 0, 0);
Delete3DTextLabel(label); //Delete 3d text label saying "Admin On Duty!"
since it wont work
__________________
NOOB
showarn is offline   Reply With Quote
Old 04/12/2012, 06:08 AM   #8
Vince
Godfather
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 6,844
Reputation: 1802
Default Re: [ZCMD] How to make Admin duty command.

Quote:
Originally Posted by showarn View Post
the script is kinda bugged with the


since it wont work
I was about to say that. Scope of the variable 'label' is all wrong.
__________________

I am not your "bro", not your "nigga" and not your friend.
Vince is offline   Reply With Quote
Old 25/12/2012, 11:34 AM   #9
Djean
Gangsta
 
Djean's Avatar
 
Join Date: Jul 2012
Location: Jamaica
Posts: 634
Reputation: 23
Default Re: [ZCMD] How to make Admin duty command.

Not much of a tutorial but it is good to use.
__________________





Djean is offline   Reply With Quote
Old 10/11/2013, 02:03 PM   #10
Godmask
Little Clucker
 
Join Date: Jun 2013
Posts: 4
Reputation: 0
Default Re: [ZCMD] How to make Admin duty command.

Nice. Might use
Godmask is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Admin Duty Command State_Trooper Scripting Help 7 06/03/2014 05:17 AM
how i can add command /duty for admin only alking282 Scripting Help 32 14/04/2012 11:32 AM
[HelpPls] iam need make command for admin name /duty alking282 Scripting Help 4 13/04/2012 10:19 PM
Admin On Duty command help darkknight123 Help Archive 2 12/01/2011 03:59 PM


All times are GMT. The time now is 12:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.