HELP! +REP
#1

Hello, I'm making a basic admin system. I'm following the tutorial on SA-MP Wiki. It says you will be needing something to do with "ReturnUser". There is a link, but when you click on it it just leads you to SA-MP boards. What do I add to make this work:

pawn Код:
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;
       if (IsPlayerAdmin(playerid))
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Player will obtain admin.");
                       return 1;
               }
               giveplayerid = ReturnUser(tmp);
               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 given by %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 if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not currently on the server.", giveplayerid);
                       SendClientMessage(playerid, 0xE60000FF, string);
               }
       }
       else
       {
           SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin, or an owner!");
       }
       return 1;
}
    return 0;
Compiler:
pawn Код:
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(142) : error 017: undefined symbol "ReturnUser"
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(154) : warning 217: loose indentation
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(168) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

Try This
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/makeadmin", true) == 0)
{
    new string[128];
   
    new tmp[256];
    tmp = strtok(cmdtext, idx);
   
    new ReturnUser;
    new giveplayerid;
    new player[MAX_PLAYER_NAME];
   
    new giveplayer[MAX_PLAYER_NAME];
    giveplayerid = ReturnUser(tmp);
    if (IsPlayerAdmin(playerid))
    {
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /makeadmin [playerid] [level]");
        SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Player will obtain 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 given by %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 if(giveplayerid == INVALID_PLAYER_ID)
    {
        format(string, sizeof(string), "%i is not currently on the server.", giveplayerid);
        SendClientMessage(playerid, 0xE60000FF, string);
    }
    }
    else
    {
        SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin, or an owner!");
    }
    return 1;
    }
    return 0;
}
Reply
#3

I'd really suggest to use ZCMD + SSCANF.
Reply
#4

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
I'd really suggest to use ZCMD + SSCANF.
How would I do that?
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
Try This
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/makeadmin", true) == 0)
{
    new string[128], tmp[256], giveplayerid;
    new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
    new ReturnUser;
    if (IsPlayerAdmin(playerid))
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /makeadmin [playerid] [level]");
        SendClientMessage(playerid, COLOUR_ORANGE, "FUNCTION: Player will obtain admin.");
        return 1;
    }
    giveplayerid = ReturnUser(tmp);
    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 given by %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 if(giveplayerid == INVALID_PLAYER_ID)
    {
        format(string, sizeof(string), "%i is not currently on the server.", giveplayerid);
        SendClientMessage(playerid, 0xE60000FF, string);
    }
    }
    else
    {
        SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin, or an owner!");
    }
    return 1;
    }
    return 0;
}
Код:
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(138) : error 012: invalid function call, not a valid address
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(138) : warning 215: expression has no effect
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(138) : error 001: expected token: ";", but found ")"
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(138) : error 029: invalid expression, assumed zero
C:\Users\Zach\Desktop\PAWNO\gamemodes\BasicAdminScript.pwn(138) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#6

Click it.
And I will agree with the users above, strcmp and strtok is pointless to use it since it's out dated and slow.
Reply
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Click it.
And I will agree with the users above, strcmp and strtok is pointless to use it since it's out dated and slow.
Thanks.
Reply
#8

So I've got ZCMD.
I have this pawn code so far with my admin system:
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0;
    if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /setadmin [ID] [Level 1-4]");
    if(levels > 5) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-5!");
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,red,"That user is not currently connected.");
    if(PlayerData[ID][AdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That user is already that level!");
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    if(levels == 0)
    {
        format(str, sizeof(str),"%s has changed your Admin level to %d on the server.",Nam,levels);
        SendClientMessage(ID,0xFF9900AA,str);
        format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
        SendClientMessage(playerid,0xFF9900AA,str);
        PlayerData[ID][AdminLevel] = levels;
        return 1;
    }
    format(str, sizeof(str),"%s has changed your Admin level to %d on the server.",Nam,levels);
    SendClientMessage(ID,0xFF9900AA,str);
    format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
    SendClientMessage(playerid,0xFF9900AA,str);
    PlayerData[ID][AdminLevel] = levels;
    return 1;
}
CMD:akill(playerid,params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
    if(sscanf(params,"u",ID)) return SendClientMessage(playerid,grey,"USAGE: /akill [playerid / Partofname]");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,red,"ERROR: That user is not currently connected!");
    GetPlayerName(playerid,Nam,sizeof(Nam));
    GetPlayerName(ID,pname,sizeof(pname));
    format(str,sizeof(str),"Administrator %s has been killed by an admin.",Nam);
    SendClientMessage(ID,orange,str);
    format(str,sizeof(str),"You have admin killed %s",pname);
    SendClientMessage(playerid,orange,str);
    SetPlayerHealth(ID,0);
    return 1;
}
Comiler states that there is errors:
Код:
C:\Users\Zach\Desktop\PAWNO\filterscripts\DJTAS.pwn(22) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Zach\Desktop\PAWNO\filterscripts\DJTAS.pwn(23) : error 017: undefined symbol "MAX_PLAYER_NAME"
C:\Users\Zach\Desktop\PAWNO\filterscripts\DJTAS.pwn(288) : warning 203: symbol is never used: "akill"
C:\Users\Zach\Desktop\PAWNO\filterscripts\DJTAS.pwn(288) : warning 203: symbol is never used: "setadmin"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#9

Do you include ZCMD to your script?
I'm not sure why this happens even if you're using the a_samp. Last, you can re-define them again.
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100

#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 24
Reply
#10

pawn Код:
CMD:setadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0;
    if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /setadmin [ID] [Level 1-4]");
    if(levels > 5) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-5!");
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,red,"That user is not currently connected.");
    if(PlayerData[ID][AdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That user is already that level!");
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    if(levels == 0)
    {
        format(str, sizeof(str),"%s has changed your Admin level to %d on the server.",Nam,levels);
        SendClientMessage(ID,0xFF9900AA,str);
        format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
        SendClientMessage(playerid,0xFF9900AA,str);
        PlayerData[ID][AdminLevel] = levels;
        return 1;
    }

CMD:akill(playerid,params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
    if(sscanf(params,"u",ID)) return SendClientMessage(playerid,grey,"USAGE: /akill [playerid / Partofname]");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,red,"ERROR: That user is not currently connected!");
    GetPlayerName(playerid,Nam,sizeof(Nam));
    GetPlayerName(ID,pname,sizeof(pname));
    format(str,sizeof(str),"Administrator %s has been killed by an admin.",Nam);
    SendClientMessage(ID,orange,str);
    format(str,sizeof(str),"You have admin killed %s",pname);
    SendClientMessage(playerid,orange,str);
    SetPlayerHealth(ID,0);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)