SA-MP Forums Archive
Admin rights! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Admin rights! (/showthread.php?tid=272841)



Admin rights! - samtey - 30.07.2011

Hey everybody!

I got a problem:

When I log myself in, I want to get admin-rights! Like that I am an admin, and that I got commands for admin, but only for admins!

I want /kick [playerid] [reason]
/god (I have infinite health, and I want that I can turn it off!) /god off
/teleport [playerid] (player gets teleport to ME)

Can I do this commands without YSI?


Re: Admin rights! - Kush - 30.07.2011

Yes.

Kick Command:

PHP код:
CMD:kick(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
PIDpName[MAX_PLAYER_NAME], Sender[MAX_PLAYER_NAME], Str;
        if(
sscanf(params"us[128]"PIDparams)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /kick [playerid] [reason]");
        if(!
IsPlayerConnected(PID)) return SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
        
Kick(PID);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
    }
    return 
1;

God Command:

PHP код:
CMD:god(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        
SetPlayerHealth(playerid10000000);
        
SetPlayerArmour(playerid10000000);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
    }
    return 
1;

Teleport Command:

PHP код:
CMD:teleport(playeridparams[])
{
     if(
IsPlayerAdmin)
     {
        new 
ID;
        new 
Str[64];
        if(
sscanf(params"u"ID)) SendClientMessage(playeridCOLOR_GREY"USAGE: /goto [playerid]");
        else if(
IsPlayerConnected(ID) == 0SendClientMessage(playeridCOLOR_GREY"Player is not connected!");
        else
        {
            new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(IDx+1y+1z);
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
    }
    return 
1;

Stripped from my little book of Commands...


AW: Admin rights! - samtey - 30.07.2011

Wow, thanks for helping Kush, you're great!!! Only, where should I put those cmds?

But what to do with my admin rights?


Re: Admin rights! - Markx - 30.07.2011

I would suggest you to read the SA-MP Wiki, its not good to start with asking others for help, try reading threw it and im sure you will understand everything https://sampwiki.blast.hk/


Re: Admin rights! - Kush - 30.07.2011

Your 'Admin' would be stored in a variable, and most likely saved in a file.

If your using my SII tutorial and have followed it correctly, then simply add this to each of the commands.:
PHP код:
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin]) 
    { 
You would place these commands most likely at the bottom of your script. It's ZCMD and Sscanf so, make sure you have the includes.


Re: Admin rights! - Max_Coldheart - 30.07.2011

Quote:
Originally Posted by Someone
SetPlayerHealth(playerid, 10000000);
This is not a good way to do it.
Better do it like:
pawn Код:
#define INFINITY 10000000 //This goes to top of script

CMD:god(playerid, params[])  //Defining the command name (requires ZCMD)
{
    if(IsPlayerAdmin(playerid)) //Checking if player is RCON admin
    {
        SetPlayerHealth(playerid, INFINITY);  //Setting health to defined amount
        SetPlayerArmour(playerid, INFINITY);  //Setting armour to defined amount
    }
    else //If he is NOT RCON admin
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); //Sends a message to the player
    }
    return 1; //Tells the compiler that it compiled successfully
}



AW: Admin rights! - samtey - 30.07.2011

Thank u both! Yo Kush, I did everything of ur tut!

But u didn't understand:
I want those admin-rights when I join my server!


Re: Admin rights! - Double-O-Seven - 30.07.2011

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
This is not a good way to do it.
Better do it like:
pawn Код:
#define INFINITY 10000000

CMD:god(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        SetPlayerHealth(playerid, INFINITY);
        SetPlayerArmour(playerid, INFINITY);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
    }
    return 1;
}
This does not matter at all if you are using it only there, also the actual value doesn't matter, it just must be high...
no need to define a makro for this...


Re: Admin rights! - Max_Coldheart - 30.07.2011

Quote:
Originally Posted by Double-O-Seven
Посмотреть сообщение
This does not matter at all if you are using it only there, also the actual value doesn't matter, it just must be high...
no need to define a makro for this...
But for future usages of the infinity, it is better to be defined

Quote:
Originally Posted by SA:MP
1. This forum requires that you wait 120 seconds between posts. Please try again in 70 seconds.



Re: Admin rights! - Kush - 30.07.2011

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
This is not a good way to do it.
Better do it like:
pawn Код:
#define INFINITY 10000000 //This goes to top of script

CMD:god(playerid, params[])  //Defining the command name (requires ZCMD)
{
    if(IsPlayerAdmin(playerid)) //Checking if player is RCON admin
    {
        SetPlayerHealth(playerid, INFINITY);  //Setting health to defined amount
        SetPlayerArmour(playerid, INFINITY);  //Setting armour to defined amount
    }
    else //If he is NOT RCON admin
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); //Sends a message to the player
    }
    return 1; //Tells the compiler that it compiled successfully
}
Whats the difference between yours and mines? You simply replaced my values in which what you've defined. They both work. Your method though is an example of loading a callback, within a callback. Which is totally useless.

And Samety, if your having trouble with the system PM me your Teamviewer information, I'd be more than willing to help.

Quote:
Originally Posted by Double-O-Seven
Посмотреть сообщение
This does not matter at all if you are using it only there, also the actual value doesn't matter, it just must be high...
no need to define a makro for this...
Right on Double-O!


Re: Admin rights! - Max_Coldheart - 30.07.2011

Quote:
Originally Posted by Kush
Посмотреть сообщение
Whats the difference between yours and mines? You simply replaced my values in which what you've defined. They both work. Your method though is an example of loading a callback, within a callback. Which is totally useless.

And Samety, if your having trouble with the system PM me your Teamviewer information, I'd be more than willing to help.



Right on Double-O!
My style is better to be used if you are using infinity in more places than just one.


AW: Admin rights! - samtey - 30.07.2011

Ehh Kush, the only thing I want is that the server know that I am an admin when I join the server!


Re: AW: Admin rights! - Kush - 30.07.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
Ehh Kush, the only thing I want is that the server know that I am an admin when I join the server!
Alright, since your using my tutorial you would either have to manually go into the user file and replace the value of Admin to a higher one. Or, you can create a command to give you admin.

PHP код:
CMD:makemeadmin(playeridparams[]) 

    if(
IsPlayerAdmin(playerid)) 
    { 
        
PlayerInfo[playerid][pAdmin] = 1;  
    } 
    else
    { 
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
    } 
    return 
1;

It would then set your value to 1, and in whatever command your using simply replace if(IsPlayerAdmin(playerid)) to if(PlayerInfo[playerid][pAdmin] == 1).


Re: Admin rights! - Markx - 30.07.2011

This is the right way to make a god command;

pawn Код:
//At top
#include <zcmd> //Credits to Zeex

new HasGod[MAX_PLAYERS];

public OnPlayerConnect(playerid) //This is a callback
{
    HasGod[playerid] = 0;
    return 1;
}
//Otside ANY callback
CMD:god(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(HasGod[playerid] == 0)
        {
            HasGod[playerid] = 1;
            SendClientMessage(playerid, -1, "God mode turned on!");
        }
        else if(HasGod[playerid] == 1)
        {
            HasGod[playerid] = 0;
            SendClientMessage(playerid, -1, "God mode turned off!");
        }
    }
    else return SendClientMessage(playerid, -1, "You are not an admin");
    return 1;
}

public OnPlayerUpdate(playerid) //this is a callback
{
    if(HasGod[playerid] == 1)
    {
        SetTimer("SetHealth", 100, true);
    }
    return 1;
}

forward SetHealth(playerid);
public SetHealth(playerid) //this is a callback
{
    SetPlayerHealth(playerid, 100);
    return 1;
}
You have to download Zcmd include and put it into [yourserver name]/pawno/includes.


AW: Admin rights! - samtey - 30.07.2011

So from where should the server know, that when I type /makemeadmin that it's me?
It could be every player who types this!

@Markx

What's wrong with Kush's god command?


Re: AW: Admin rights! - Kush - 30.07.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
So from where should the server know, that when I type /makemeadmin that it's me?
It could be every player who types this!

@Markx

What's wrong with Kush's god command?
Apparently his is more 'baws' as it contains a timer and uses the OnPlayerUpdate callback which checks around 32 times a second.

ON-TOPIC: /makemeadmin was a mere example. It would simply set your 'Admin' value to 1. Once at 1, you would then be allowed to use God, Teleport and Kick.


Re: AW: Admin rights! - Markx - 30.07.2011

Quote:
Originally Posted by Kush
Посмотреть сообщение
Apparently his is more 'baws' as it contains a timer and uses the OnPlayerUpdate callback which checks around 32 times a second.

ON-TOPIC: /makemeadmin was a mere example. It would simply set your 'Admin' value to 1. Once at 1, you would then be allowed to use God, Teleport and Kick.
Your god command wont hold all the time, after some time, you will die. e.g. get shoot by a minigun would kill you after like 30 seconds or more. Mine cant kill you and its infinity. The timer is to prevent possible lag, you can set it to 1 second so theres even lower chance to get lag.


AW: Re: AW: Admin rights! - samtey - 30.07.2011

Quote:
Originally Posted by Kush
Посмотреть сообщение
Apparently his is more 'baws' as it contains a timer and uses the OnPlayerUpdate callback which checks around 32 times a second.

ON-TOPIC: /makemeadmin was a mere example. It would simply set your 'Admin' value to 1. Once at 1, you would then be allowed to use God, Teleport and Kick.
Where should I set admin-value to 1 o_O


Re: AW: Admin rights! - Kush - 30.07.2011

Quote:
Originally Posted by Markx
Посмотреть сообщение
Your god command wont hold all the time, after some time, you will die. e.g. get shoot by a minigun would kill you after like 30 seconds or more. Mine cant kill you and its infinity. The timer is to prevent possible lag, you can set it to 1 second so theres even lower chance to get lag.
In comparison to a timer and a value being set, your saying that the timer will cause less lag? The function is going to be called directly, yours won't. And by the way, it would make no sense to go through all that hassle for a simple god mode command. If anyone should be worried about dieing, set your health to a random '9999999999999999999999999999999999999999999999999 9999999999999999999999999999', but yet you can't set it to that in SAMP as there is a limit.

Quote:
Originally Posted by samtey
Посмотреть сообщение
Where should I set admin-value to 1 o_O
Just locate the user file and simply replace the value to 1.