AdminScript Help.
#1

Hello my names Mike
A.K.A SublimESmokeR420 - You can call me Sub, Smoke, Smoker, Sublime, or 420. What ever suites you.

I'm making my own AdminScript and i want to change the Levels of Admins that can use the commands.
For Example.: if(gPlayerInfo[playerid][PLAYER_LEVEL] <= 1) <-- This means that the Admin (Level of the Admin) can use this command. The " <= 1) " Means that a Level 1 Admin can use this.

And what i want to change is some of my commands are for RCON login ONLY. I want to change that.
But when I try to use it, i get A bunch of Errors. This is what a RCON login ONLY command looks like.
For Example:
dcmd_setscore(playerid, params[])
{
new amount;
new pName[MAX_PLAYER_NAME];
GetPlayerScore(playerid);
GetPlayerName(playerid, pName, sizeof(pName));

I want to make that command so that an Admin Level 1 can use it. But when i try to change it. It gives me Errors. This command by the way is ONLY for RCON admins.

I need HELP very BADLY.
You can get me on skype
Either one:
Mike Dunne
or
SublimESmokeR420SAMP
or just incase:
sublimesmoker420samp
.
~Mike
Reply
#2

Well only RCON would just use IsPlayerAdmin(playerid) I would think..

EDIT: Also, it would have to be (gPlayerInfo[playerid][PLAYER_LEVEL] >= 1) if you wanted it to be level 1 and above, because using <= would mean someone who wasn't an admin could use it. If you wanted ONLY level 1, you could just use '==' rather than a '>'.
Reply
#3

An example, only for Rcon admins:
pawn Код:
dcmd_COMMAND(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, -1, "You're not an Rcon admin.");

    //code...
    return 1;
}
This
pawn Код:
if(gPlayerInfo[playerid][PLAYER_LEVEL] <= 1)
means if the player is admin 1 or lower than 1...
Reply
#4

Yea, Thanks guys... I didn't understand the <= and the >= and the == ... But i still need help. When i do that it just comes up with an "Error: Unidentified simple... Which pisses me off like seriously. I'm new to scripting, and learning all three. And maybe four things. Mapping, Scripting, Stcrmp, And Dcmd... Very difficult. And help from all you + Wiki and Weedarr is soooo help full. Thanks guys.

(Still need help tho.)
Reply
#5

Add on skype: Willian_luigi
Reply
#6

Kay, I did.
Reply
#7

Thanks to you guy's i figured out the errors. But i Can NOT seem to figure this one out...

pawn Код:
C:\SAMPServer\filterscripts\AdminScript.pwn(761) : error 036: empty statement
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
This is the Command.

pawn Код:
dcmd_sethp(playerid,params[])
{
        new pid,ammount;
        if(gPlayerInfo[playerid][PLAYER_LEVEL] >= 2);
        else if(sscanf(params,"ud",pid,ammount)) SendClientMessage(playerid,COLOR_RED,"USAGE: /sethp [ID] [Ammount]");
        else if(pid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Player was not found");
        else
        {
            new string[50],string1[50],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
            GetPlayerName(playerid,name,sizeof(name));
            GetPlayerName(pid,name2,sizeof(name2));
            SetPlayerHealth(pid,ammount);
                format(string,sizeof(string),"You have set %s's health",name2);
                format(string1,sizeof(string1),"Your health has been set by %s ",name);
                SendClientMessage(pid,COLOR_YELLOW,string1);
                SendClientMessage(playerid,COLOR_YELLOW,string);
                }
        return 1;
}
Reply
#8

Here is the correct code, don't forget to read the comments.

pawn Код:
dcmd_sethp(playerid,params[])
{
        new pid,ammount;
        if(sscanf(params,"ud",pid,ammount)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /sethp [ID] [Ammount]"); // You need return here before SendClientMessage
        if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"Player was not found"); // You needed Return Here before SendClientMessage
        if(gPlayerInfo[playerid][PLAYER_LEVEL] >= 2) // You didn't need a semi-colon(;) here.
        {
            new string[50],string1[50],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
            GetPlayerName(playerid,name,sizeof(name));
            GetPlayerName(pid,name2,sizeof(name2));
            SetPlayerHealth(pid,ammount);
            format(string,sizeof(string),"You have set %s's health",name2);         //You had loose indentation from here
            format(string1,sizeof(string1),"Your health has been set by %s ",name);
            SendClientMessage(pid,COLOR_YELLOW,string1);
            SendClientMessage(playerid,COLOR_YELLOW,string);                        //To Here
         }
        return 1;
}
If You didn't put the returns, where I put them it would look like this if you didn't do the command right:

Код:
Usage:/sethp[ID][Ammount]
Player was not found
You have set 's health
If you didn't write the a valid ID it would look like this:

Код:
Player was not found
You have set 's health
However, if you use the code I wrote, it would work perfectly fine with no errors, and just how you want it.
Reply
#9

Thank you. But i got it fixed last night. But my other commands look differently so i will maybe use your code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)