Some Questions
#1

Yo
I need some help

1. How can i change an command like /fix to a button like H?

2. When i try to add /makeadmin from SAMP Wiki
Код:
if(strcmp("/makeadmin", cmdtext, 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, COLOR_ORANGE, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, COLOR_ORANGE, "FUNCTION: Player will be an 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 thanks to %s.", level,  player);
                       SendClientMessage(giveplayerid, COLOR_WHITE, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][AdminLevel]);
                               SendClientMessage(playerid, COLOR_WHITE, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, COLOR_RED, string);
               }
       }
       else
       {
           SendClientMessage(playerid, COLOR_RED, "You are not a lead admin!");
       }
       return 1;
}
I get this

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(393) : warning 217: loose indentation
F:\Servers\SAMP\gamemodes\Esco.pwn(394) : error 017: undefined symbol "strtok"
F:\Servers\SAMP\gamemodes\Esco.pwn(394) : error 033: array must be indexed (variable "cmd")
F:\Servers\SAMP\gamemodes\Esco.pwn(403) : error 017: undefined symbol "strtok"
F:\Servers\SAMP\gamemodes\Esco.pwn(403) : error 033: array must be indexed (variable "tmp")
F:\Servers\SAMP\gamemodes\Esco.pwn(410) : error 017: undefined symbol "ReturnUser"
F:\Servers\SAMP\gamemodes\Esco.pwn(411) : error 017: undefined symbol "strtok"
F:\Servers\SAMP\gamemodes\Esco.pwn(411) : error 033: array must be indexed (variable "tmp")
F:\Servers\SAMP\gamemodes\Esco.pwn(422) : warning 217: loose indentation
F:\Servers\SAMP\gamemodes\Esco.pwn(437) : warning 217: loose indentation
F:\Servers\SAMP\gamemodes\Esco.pwn(393) : warning 203: symbol is never used: "idx"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
How can i fix that?
Reply
#2

I see some copy+pasta here.
Reply
#3

Well, i said that
Quote:
Originally Posted by MrEnd
Посмотреть сообщение
2. When i try to add /makeadmin from SAMP Wiki
Reply
#4

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(393) : warning 217: loose indentation
This simply means that the spacing is either too much, or too little.

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(394) : error 017: undefined symbol "strtok"
You need to define strtok;
pawn Код:
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;
}
Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(394) : error 033: array must be indexed (variable "cmd")
Ontop of
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
put
pawn Код:
new cmd[128];// You can use 256 but highly not
recommended.
Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(403) : error 033: array must be indexed (variable "tmp")
Instead of defining temp[256] in the command, place it on OnPlayerCommandText as-well.

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(410) : error 017: undefined symbol "ReturnUser"
You need to define ReturnUser
pawn Код:
ReturnUser(text[]) {

    new
        strPos,
        returnID = 0,
        bool: isnum = true;

    while(text[strPos]) {
        if(isnum) {
            if ('0' <= text[strPos] <= '9') returnID = (returnID * 10) + (text[strPos] - '0');
            else isnum = false;
        }
        strPos++;
    }
    if (isnum) {
        if(IsPlayerConnected(returnID)) return returnID;
    }
    else {

        new
            sz_playerName[MAX_PLAYER_NAME];

        foreach(Player, i) {
            GetPlayerName(i, sz_playerName, MAX_PLAYER_NAME);
            if(!strcmp(sz_playerName, text, true, strPos)) return i;
        }
    }
    return INVALID_PLAYER_ID;
}
Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(393) : warning 203: symbol is never used: "idx"
This is simply not being read, due to the other errors, once you fix them it should fix itself.
If it doesn't then it means it's truly not being used and to fix that all you have to do is delete
pawn Код:
new idx;
Hope this helped you!
Reply
#5

Uhm, when i fixed something other on the server i think it got fixed by it self..

now i just got
Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(696) : error 021: symbol already defined: "cmd"
F:\Servers\SAMP\gamemodes\Esco.pwn(713) : error 017: undefined symbol "ReturnUser"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
How to fix that? :P

Btw, tnx for taking your the time to reply Lynn
Reply
#6

delete that new cmd[128]; somewhere then copy the code that Lynn gave (the ReturnUser)

EDIT:

Copy the code that Lynn gives that ReturnUser.
then remove that new cmd somewhere
Reply
#7

Quote:
Originally Posted by Reklez
Посмотреть сообщение
delete that new cmd[128]; somewhere then copy the code that Lynn gave (the ReturnUser)

EDIT:

Copy the code that Lynn gives that ReturnUser.
then remove that new cmd somewhere
Haha i tryed and i found it before you answered :P I fixed 3 errors more after i posted :P But edited the reply :P
Tnx I try

EDIT

But, where to paste
Код:
ReturnUser(text[]) {

    new
        strPos,
        returnID = 0,
        bool: isnum = true;

    while(text[strPos]) {
        if(isnum) {
            if ('0' <= text[strPos] <= '9') returnID = (returnID * 10) + (text[strPos] - '0');
            else isnum = false;
        }
        strPos++;
    }
    if (isnum) {
        if(IsPlayerConnected(returnID)) return returnID;
    }
    else {

        new
            sz_playerName[MAX_PLAYER_NAME];

        foreach(Player, i) {
            GetPlayerName(i, sz_playerName, MAX_PLAYER_NAME);
            if(!strcmp(sz_playerName, text, true, strPos)) return i;
        }
    }
    return INVALID_PLAYER_ID;
}
?
Reply
#8

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(696) : error 021: symbol already defined: "cmd"
This means you're defining [pawn]new cmd[256]; or [128] twice.
So remove the
pawn Код:
new cmd[128/256];
from the Command, and only have it under
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
(At the very top of it, as a global define(For that public.)

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(713) : error 017: undefined symbol "ReturnUser"
This means you haven't placed the ReturnUser yet.
I suggest placing the code in above post for ReturnUser at the very bottom of your script.

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(720) : error 017: undefined symbol "AdminLevel"
This means that where you use;
pawn Код:
PlayerInfo[giveplayerid][AdminLevel]
The AdminLevel isn't being define.
Now, since you're using PlayerInfo, that probably means you're also using
pawn Код:
enum pInfo
{
//Information here
};
new PlayerInfo[MAX_PLAYERS][pInfo];
// Under enum pInfo { place AdminLevel,
//So it'd look for instance
enum pInfo
{
    AdminLevel,
    pJob, // Don't add this, just part of the example
    pCash, // Don't add this, just part of the example
};
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#9

Well lol Lynn reply late. that undefined symbol: "AdminLevel" is fix
MrEnd you should put it anywhere but not before #include <a_samp>

Just put it at the end of the script
Reply
#10

Haha damn Lynn
The only left now is
Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(713) : error 017: undefined symbol "ReturnUser"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Errors.
and when i pasted that ReturUser thing on the button on my script i got

Код:
F:\Servers\SAMP\gamemodes\Esco.pwn(868) : error 017: undefined symbol "foreach"
F:\Servers\SAMP\gamemodes\Esco.pwn(869) : error 017: undefined symbol "i"
F:\Servers\SAMP\gamemodes\Esco.pwn(870) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)