New Problem
#1

hi ill post the code and tell the problem

Код:
#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), "%s(%i) is not online right now, Sorry.", giveplayer, giveplayerid);
                SendClientMessage(playerid, 0xE60000FF, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
        }
        return 1;

    }
    return 1;
}
whoever i select and the level it always gives that player Lvl 0 admin anyone know why

here is the full 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), "%s(%i) is not online right now, Sorry.", giveplayer, giveplayerid);
                SendClientMessage(playerid, 0xE60000FF, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
        }
        return 1;

    }
    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);

        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.");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(kickplayerid != INVALID_PLAYER_ID)
            {
                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.", kickplayer);
                SendClientMessage(playerid, 0x00c2ecff, string);
                Kick(kickplayerid);
            }
            else
            {
                format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", kickplayer, kickplayerid);
                SendClientMessage(playerid, 0x00c2ecff, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE6000FF, "You Are Not A Moderator!");
        }
        return 1;
    }
    if(strcmp(cmd, "/Ban", true) == 0)
    {
        new string[128];
        new tmp[256];
        new player[MAX_PLAYER_NAME], banplayer[MAX_PLAYER_NAME];
        new banplayerid;
        new reason;
        tmp = strtok(cmdtext, idx);
        banplayerid= strval(tmp);

        if(PlayerInfo[playerid][AdminLevel] == 2)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /Ban [playerid] [reason].");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Bans a player.");
                return 1;
            }
            if(banplayerid != INVALID_PLAYER_ID)
            {
                tmp = strtok(cmdtext, idx);
                GetPlayerName(banplayerid, banplayer, sizeof(banplayer));
                GetPlayerName(playerid, player, sizeof(player));
                printf("Admin: %s Has Banned: %s Because: %d.", player, banplayer, reason);
                format(string, sizeof(string), "You Have Been Banned By: %s Because: %d.", player, reason);
                SendClientMessage(banplayerid, 0x00c2ecff, string);
                format(string, sizeof(string), "You Have Banned: %s Because: %d.", banplayer, reason);
                SendClientMessage(playerid, 0x00c2ecff, string);
                Ban(banplayerid);
            }
            else
            {
                format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", banplayer, banplayerid);
                SendClientMessage(playerid, 0x00c2ecff, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE60000FF, "You Are Not a Super Moderator!");
        }
        return 1;
    }
    if(strcmp(cmd, "/Get", true) == 0)
    {
        new string[128];
        new tmp[256];
        new player[MAX_PLAYER_NAME], getplayer[MAX_PLAYER_NAME];
        new getplayerid;
        tmp = strtok(cmdtext, idx);
        getplayerid = strval(tmp);

        if(PlayerInfo[playerid][AdminLevel] == 1)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /Get [playerid].");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Gets a player.");
                return 1;
            }
            if(getplayerid != INVALID_PLAYER_ID)
            {
                tmp = strtok(cmdtext, idx);
                new Float:X, Float:Y, Float:Z;
                GetPlayerName(getplayerid, getplayer, sizeof(getplayer));
                GetPlayerName(playerid, player, sizeof(player));
                GetPlayerPos(playerid, X, Y, Z);
                printf("Admin: %s Has Gotten: %s.", player, getplayer);
                format(string, sizeof(string), "You Have Been Teleported to Admin: %s Position.", player);
                SendClientMessage(getplayerid, 0x00c2ecff, string);
                format(string, sizeof(string), "You Have Teleported: %s to you.", getplayer);
                SendClientMessage(playerid, 0x00c2ecff, string);
                SetPlayerPos(getplayerid, X, Y, Z);
            }
            else
            {
                format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", getplayer, getplayerid);
                SendClientMessage(playerid, 0x00c2ecff, string);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xE60000FF, "You Are Not a moderator!");
        }
        return 1;
    }
    if(strcmp(cmd, "/Goto", true) == 0)
    {
        new string[128];
        new tmp[256];
        new player[MAX_PLAYER_NAME], gotoplayer[MAX_PLAYER_NAME];
        new gotoplayerid;
        tmp = strtok(cmdtext, idx);
        gotoplayerid = strval(tmp);
        
        if(PlayerInfo[playerid][AdminLevel] == 1)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /Goto [playerid].");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Sets your position to that of the selected player");
                return 1;
			}
			if(gotoplayerid != INVALID_PLAYER_ID)
			{
			    tmp = strtok(cmdtext, idx);
			    new Float:X, Float:Y, Float:Z;
                GetPlayerName(gotoplayerid, gotoplayer, sizeof(gotoplayer));
                GetPlayerName(playerid, player, sizeof(player));
                GetPlayerPos(gotoplayerid, X, Y, Z);
                printf("Admin: %s Has Teleported to: %s.", player, gotoplayer);
                format(string, sizeof(string), "You Have Teleported to: %s.", gotoplayer);
                SendClientMessage(playerid, 0x00c2ecff, string);
                SetPlayerPos(playerid, X, Y, Z);
			}
			else
			{
			    format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", gotoplayer, gotoplayerid);
			    SendClientMessage(playerid, 0x00c2ecff, string);
			}
		}
		else
		{
		    SendClientMessage(playerid, 0xE60000FF, "You Are Not a Moderator!");
		}
		return 1;
	}
    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;
}
Please Help this script is vital for my server
Reply
#2

Save your AdminLevel.
MySQL:https://sampforum.blast.hk/showthread.php?tid=159785
DOF2:https://sampforum.blast.hk/showthread.php?tid=281736
Y_INI:https://sampforum.blast.hk/showthread.php?tid=273088
SQLite:https://sampforum.blast.hk/showthread.php?tid=278188
Reply
#3

u dont get me i keeps giving whoever i type level 0 not the level i type
Reply
#4

anyone? Sorry for bumping
Reply
#5

Use sscanf - would save you lots of lines and its LOTS of times easier to use, efficient and faster!
Reply
#6

thats not the problem dude its the script itself it sets the level to 0 but i made this script using a tut on the SAMP forum
Reply
#7

Just my simple guess.

Your Code:
pawn Код:
enum Info
{
    AdminLevel
};
My Guessed Fix:
pawn Код:
enum Info
{
    AdminLevel,
};
If that doesnt fix it you need to provide more info, what saving system are you using? Ohterwise not much help can be given.
Reply
#8

Quote:
Originally Posted by SantarioLeone
Посмотреть сообщение
Just my simple guess.

Your Code:
pawn Код:
enum Info
{
    AdminLevel
};
My Guessed Fix:
pawn Код:
enum Info
{
    AdminLevel,
};
If that doesnt fix it you need to provide more info, what saving system are you using? Ohterwise not much help can be given.
I suggest you learning pawn basics before helping.
If that ever fixes it, I am going to jump out of the window.
And her problem is not the saving system, it is the params, which returns 0.
Reply
#9

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
I suggest you learning pawn basics before helping.
If that ever fixes it, I am going to jump out of the window.
And her problem is not the saving system, it is the params, which returns 0.
As i said it was a "GUESS" as its worked for me before, and in majority of all scripts after putting something in a Enum, its followed by a ",". So again i GUESSED that would fix, it and i asked him for his saving system to see if that could be an issue saving his admin level, Read before posting it was a GUESS so dont worry about my attempts to help another person if it doesnt work it doesnt work, if it does it does. You can keep your Suggestions directed toward the Author of the post.
Reply
#10

listen the comma is only for more than one item so its like mow

Код:
enum info
{
    AdminLevel
};
but if i had more than 1 it would be
Код:
enum info
{
    AdminLevel,
    pass
};
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)