/makeadmin help
#1

I was make command /makeadmin but I have error

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
   if(!strcmp(cmdtext, "/me", true, 3))
    {
      if(IsPlayerAdmin(playerid))
      {
          if(cmdtext[3] == 0) {
               SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [radnja]");
               return 1;
           }
           new str[128];
           GetPlayerName(playerid, str, sizeof(str));
           format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
           SendClientMessageToAll(0xFFFF00AA, str);
           return 1;
      }
      else
      {
      SendClientMessage(playerid,0x00AAAA00,"Test");
      }
    }
    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)) // provjerava jeli igrac RCON admin
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, ORANGE, "KORISTENJE: /makeadmin [ime/id] [level]");
                       SendClientMessage(playerid, ORANGE, "FUNKCIJA: Igrac ce biti 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 je stavio %s level %d admina.", player, giveplayer, level);
                       format(string, sizeof(string), "Sada ste admin level %d ,zahvaljujuci %s.", level,  player);
                       SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                       format(string, sizeof(string), "Dali ste %s level %d admina.",  giveplayer,PlayerInfo[giveplayerid][AdminLevel]);
                               SendClientMessage(playerid, 0x00C2ECFF, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i nije online.", giveplayerid);
                       SendClientMessage(playerid, 0xE60000FF, string);
               }
       }
       else
       {
           SendClientMessage(playerid, 0xE60000FF, "Niste head admin!");
       }
   }
   return SendClientMessage(playerid,0x00AAAA00, "You was enter wrong command, ask admin abot help or type /help /help1 /help2");
}
errors:
E:\5STARS~1\GAMEMO~1\5stars.pwn(134) : error 017: undefined symbol "ReturnUser"
E:\5STARS~1\GAMEMO~1\5stars.pwn(296) : warning 203: symbol is never used: "ret_memcpy"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

I can help you with the warning. put

Код:
#pragma unused ret_memcpy
at the top of your script

Also where is returnuser?

Take a look here

https://sampforum.blast.hk/showthread.php?tid=111558

Make sure you got the
Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
Reply
#3

Add this at bottom of your script:
PHP код:
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if (
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos])) // Check whole passed string
    
{
        
userid strval(text[pos]);
        if (
userid >= && userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
            {
                
userid INVALID_PLAYER_ID;
            }
            else
            {
                return 
userid// A player was found
            
}
        }
    }
    
// They entered [part of] a name or the id search failed (check names just incase)
    
new len strlen(text[pos]);
    new 
count 0;
    new 
name[MAX_PLAYER_NAME];
    catch(
Playeri)
    {
        
GetPlayerName(inamesizeof (name));
        if (
strcmp(nametext[pos], truelen) == 0// Check segment of name
        
{
            if (
len == strlen(name)) // Exact match
            
{
                return 
i// Return the exact player on an exact match
                // Otherwise if there are two players:
                // Me and MeYou any time you entered Me it would find both
                // And never be able to return just Me's id
            
}
            else 
// Partial match
            
{
                
count++;
                
userid i;
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
count)
            {
                
SendClientMessage(playerid0xFF0000AA"Au fost gasiti mai multi utilizatori, te rugam sa cauti mai detaliat");
            }
            else
            {
                
SendClientMessage(playerid0xFF0000AA"Nu a fost gasit un utilizator potrivit");
            }
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid// INVALID_USER_ID for bad return

Reply
#4

giveplayerid = ReturnUser(tmp); there
tmp = strtok(cmdtext, idx);
new level = strval(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
Reply
#5

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
I was copying a command /makeadmin but I have error
Fixed.

Further, please refrain from using outdated methods. Use ZCMD and sscanf. Much easier once you get the hang of it.
Reply
#6

moro im sorry
E:\5STARS~1\GAMEMO~1\5stars.pwn(23) : error 017: undefined symbol "IsNumeric"
E:\5STARS~1\GAMEMO~1\5stars.pwn(42) : error 017: undefined symbol "catch"
E:\5STARS~1\GAMEMO~1\5stars.pwn(44) : error 017: undefined symbol "i"
E:\5STARS~1\GAMEMO~1\5stars.pwn(49) : error 017: undefined symbol "i"
E:\5STARS~1\GAMEMO~1\5stars.pwn(57) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.
xD
Reply
#7

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
moro im sorry
E:\5STARS~1\GAMEMO~1\5stars.pwn(23) : error 017: undefined symbol "IsNumeric"
E:\5STARS~1\GAMEMO~1\5stars.pwn(42) : error 017: undefined symbol "catch"
E:\5STARS~1\GAMEMO~1\5stars.pwn(44) : error 017: undefined symbol "i"
E:\5STARS~1\GAMEMO~1\5stars.pwn(49) : error 017: undefined symbol "i"
E:\5STARS~1\GAMEMO~1\5stars.pwn(57) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.
xD
Oh sorry:
PHP код:
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if (
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos])) // Check whole passed string
    
{
        
userid strval(text[pos]);
        if (
userid >= && userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
            {
                
userid INVALID_PLAYER_ID;
            }
            else
            {
                return 
userid// A player was found
            
}
        }
    }
    
// They entered [part of] a name or the id search failed (check names just incase)
    
new len strlen(text[pos]);
    new 
count 0;
    new 
name[MAX_PLAYER_NAME];
    for(new 
0MAX_PLAYERSi++)
    {
        
GetPlayerName(inamesizeof (name));
        if (
strcmp(nametext[pos], truelen) == 0// Check segment of name
        
{
            if (
len == strlen(name)) // Exact match
            
{
                return 
i// Return the exact player on an exact match
                // Otherwise if there are two players:
                // Me and MeYou any time you entered Me it would find both
                // And never be able to return just Me's id
            
}
            else 
// Partial match
            
{
                
count++;
                
userid i;
            }
        }
    }
    if (
count != 1)
    {
        
userid INVALID_PLAYER_ID;
    }
    return 
userid// INVALID_USER_ID for bad return
}
IsNumeric(const string[])
{
    for (new 
0strlen(string); ji++)
    {
        if (
string[i] > '9' || string[i] < '0') return 0;
    }
    return 
1;

Reply
#8

moro thank you soo much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)