Trouble With My Admin Script
#1

New Edit I am getting a bit of trouble on a else statement now i sorted everthing else out here is the code:

Код:
#include <a_samp>

#define ORANGE 0xAAFF00FF

enum Info
{
    AdminLevel
};

new PlayerInfo[MAX_PLAYERS][Info];

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/makeadmin", true) == 0)
    {
        new string[128];
        new tmp[256];
        new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
        new giveplayerid;
        tmp = strtok(cmdtext, idx);
        giveplayerid = strval(tmp);

        if (IsPlayerAdmin(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /makeadmin [playerid] [level]");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Player will be an admin.");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            new level = strval(tmp);
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, player, sizeof(player));
                PlayerInfo[giveplayerid][AdminLevel] = level;
                printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
                SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]);
                SendClientMessage(playerid, 0x00C2ECFF, string);
            }
            else
            {
                format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                SendClientMessage(playerid, 0xE60000FF, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
        }

    }
    if(strcmp(cmd, "/Admin_Commands", true) == 0)
    {
        SendClientMessage(playerid, ORANGE, "This Command Is A Work In Progress Untill BAdmin Is Complete");
        return 1;
    }
	if(strcmp(cmd, "/Kick", true) == 0)
	{
	    new string[128];
	    new tmp[256];
	    new player[MAX_PLAYER_NAME], kickplayer[MAX_PLAYER_NAME];
	    new kickplayerid;
	    tmp = strtok(cmdtext, idx);
	    kickplayerid = strval(tmp);
	    
	    PlayerInfo[playerid][AdminLevel] = 1;
	    {
	        tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /kick [playerid] ");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Kick a player.");
                return 1;
            }
	        tmp = strtok(cmdtext, idx);
	        GetPlayerName(kickplayerid, kickplayer, sizeof(kickplayer));
	        GetPlayerName(playerid, player, sizeof(player));
	        printf("Admin %s Has Kicked %s.", player, kickplayer);
	        format(string, sizeof(string), "You Have Been Kicked By %s.", player);
	        SendClientMessage(kickplayerid, 0x00c2ecff, string);
	        format(string, sizeof(string), "You Have Kicked %s.", kickplayerid);
            SendClientMessage(playerid, 0x00c2ecff, string);
            Kick(kickplayerid);
       	}
        else
        {
		    format(string, sizeof(string), "%i is not online right now, Sorry.", kickplayerid);
            SendClientMessage(playerid, 0x00c2ecff, string);
		}
	}
	else
	{
	    SendClientMessage(playerid, 0xE6000FF, "You Are Not A Moderator!");
	}
    return 1;
}

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][AdminLevel] = 0;
    return 1;
}

stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Error line:
Код:
       	}
        else
        {
New Errors:
Код:
C:\DOCUME~1\*****\Desktop\SA8BEC~1\FILTER~1\ADMIN_~1.PWN(92) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

pawn Код:
if(Info[AdminLevel] = 1;
Should be
pawn Код:
if(Info[AdminLevel] == 1)
As well assure that you have this enum...
Reply
#3

PHP код:
if(Info[AdminLevel] == 1
Edit: [MWR]Blood was faster.
Reply
#4

ive edited now i have a new problem
Reply
#5

Lol, well, tell us the problem.
Reply
#6

pawn Код:
if(strcmp(cmd, "/Kick", true) == 0)
    {
        new string[128];
        new tmp[256];
        new player[MAX_PLAYER_NAME], kickplayer[MAX_PLAYER_NAME];
        new kickplayerid;
        tmp = strtok(cmdtext, idx);
        kickplayerid = strval(tmp);
        if(PlayerInfo[playerid][AdminLevel] == 1)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /kick [playerid] ");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Kick a player.");
            }
            tmp = strtok(cmdtext, idx);
            GetPlayerName(kickplayerid, kickplayer, sizeof(kickplayer));
            GetPlayerName(playerid, player, sizeof(player));
            printf("Admin %s Has Kicked %s.", player, kickplayer);
            format(string, sizeof(string), "You Have Been Kicked By %s.", player);
            SendClientMessage(kickplayerid, 0x00c2ecff, string);
            format(string, sizeof(string), "You Have Kicked %s.", kickplayerid);
            SendClientMessage(playerid, 0x00c2ecff, string);
            Kick(kickplayerid);
            }
            else
            {
                format(string, sizeof(string), "%i is not online right now, Sorry.", kickplayerid);
                SendClientMessage(playerid, 0x00c2ecff, string);
            }
    }
    else
    {
        SendClientMessage(playerid, 0xE6000FF, "You Are Not A Moderator!");
    }
    return 1;
}
Reply
#7

edit thanks it compiles now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)