A Little Help
#1

Hello,
Код:
if(strcmp(cmdtext,"/god",true)==0)
    {
    if(pAdmin[playerid] == 1)
    {
    if(God[playerid] == 0)
    {
    God[playerid] = 1;
    SendClientMessage(playerid,COLOR_GREEN,"God Mode On");
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"%s is a God",name);
    SendClientMessageToAll(COLOR_BLUE,string);
    }
    else
    {
    God[playerid] = 0;
    SendClientMessage(playerid,COLOR_RED,"God Mode Off");
    SetPlayerHealth(playerid, 100);
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"%s is a God no more",name);
    SendClientMessageToAll(COLOR_BLUE,string);
    }
    }
    else
    {
    SendClientMessage(playerid,COLOR_RED,"You Are Not An Admin!);
    }
    return 1;
    }
I made this code it seems to have no problem, but when i compile it.
Quote:

D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2322) : error 017: undefined symbol "string"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2322) : error 017: undefined symbol "string"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2322) : error 029: invalid expression, assumed zero
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2322) : fatal error 107: too many error messages on one line

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


4 Errors.

These Errors Pop up.
Any kind of help will be appreciated!
Reply
#2

pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
    new string[256];
    if(pAdmin[playerid] == 1)
    {
        if(God[playerid] == 0)
        {
            God[playerid] = 1;
            SendClientMessage(playerid,COLOR_GREEN,"God Mode On");
            GetPlayerName(playerid,name,sizeof(name));
            format(string,sizeof(string),"%s is a God",name);
            SendClientMessageToAll(COLOR_BLUE,string);
        }
        else
        {
            God[playerid] = 0;
            SendClientMessage(playerid,COLOR_RED,"God Mode Off");
            SetPlayerHealth(playerid, 100);
            GetPlayerName(playerid,name,sizeof(name));
            format(string,sizeof(string),"%s is a God no more",name);
            SendClientMessageToAll(COLOR_BLUE,string);
        }
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"You Are Not An Admin!);
    }
    return 1;
}
Try This Untested Version

EDIT: Also Try To Mention Line Containing Error Which line is that
Reply
#3

pawn Код:
if(strcmp(cmdtext,"/god",true)==0)
{
    if(pAdmin[playerid] != 1) return SendClientMessage(playerid,COLOR_RED,"You Are Not An Admin!");
    new string[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(God[playerid] == 0)
    {
        God[playerid] = 1;
        SendClientMessage(playerid,COLOR_GREEN,"God Mode On");
        format(string,sizeof(string),"%s is a God",name);
        SendClientMessageToAll(COLOR_BLUE,string);
    }
    else
    {
        God[playerid] = 0;
        SendClientMessage(playerid,COLOR_RED,"God Mode Off");
        SetPlayerHealth(playerid, 100);
        format(string,sizeof(string),"%s is a God no more",name);
        SendClientMessageToAll(COLOR_BLUE,string);
    }
    return 1;
}
Reply
#4

You don't need a cell of 256, it's just useless.
pawn Код:
if(strcmp(cmdtext, "/god", true) == 0) {
    new string[128];
    if(pAdmin[playerid] == 1) {
        if(God[playerid] == 0) {
            God[playerid] = 1;
            SendClientMessage(playerid, COLOR_GREEN, "God Mode On");
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s is a God", name);
            return SendClientMessageToAll(COLOR_BLUE, string);
        }
        else {
            God[playerid] = 0;
            SendClientMessage(playerid, COLOR_RED, "God Mode Off");
            SetPlayerHealth(playerid, 100);
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s is a God no more", name);
            return SendClientMessageToAll(COLOR_BLUE, string);
        }
    }
    else return SendClientMessage(playerid,COLOR_RED,"You Are Not An Admin!);
}
Reply
#5

Oh, mb i forgot to put strings there x(.
thank you it works now cheers!
Reply
#6

uhh, AFK system has some problems also
Код:
if(strcmp("/afk",cmd,true) == 0}
    {
    new tmp[256];
    tmp = strtok(cmdtext,index);

    if(afk[playerid] == 0)
    {
    if(!strlen(tmp))
    {
    SendClientMessage(playerid,COLOR_RED,"Usage:/afk[reason]");
    return 1;
    }
	afk[playerid] = 1;
    new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "WARNING->%s Is AFK [Reason->%s]<-WARNING", playername,tmp);
    SendClientMessageToAll(COLOR_YELLOW, string);
    TogglePlayerControllable(playerid,0);
    }
    else
    {
	afk[playerid] = 0;
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "->%s Is Back On Keyboard<-", playername);
    SendClientMessageToAll(COLOR_YELLOW, string);
    TogglePlayerControllable(playerid,1);
    SetPlayerHealth(playerid,100);
    }
    return 1;
    }
can someone help me with it?
ERRORS:
Quote:

D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2153) : error 017: undefined symbol "cmd"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2153) : error 029: invalid expression, assumed zero
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2156) : error 017: undefined symbol "strtok"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(2156) : error 033: array must be indexed (variable "tmp")
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(216 : error 017: undefined symbol "string"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(216 : error 017: undefined symbol "string"
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(216 : error 029: invalid expression, assumed zero
D:\Game Softs\0.3D\gamemodes\LDriftGM.pwn(216 : fatal error 107: too many error messages on one line

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


8 Errors.

Reply
#7

mention the lines buddy how can we know which error is on which line
Reply
#8

i just dont understand how should i mention the lines x(
Reply
#9

Here is the code of afk replace it i fixed it
pawn Код:
if(strcmp("/afk",cmd,true) == 0)
{
    new tmp[256], cmd[128];
    new string[256], index;
    tmp = strtok(cmdtext,index);
    if(afk[playerid] == 0)
    {
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,COLOR_RED,"Usage:/afk[reason]");
            return 1;
        }
        afk[playerid] = 1;
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "WARNING->%s Is AFK [Reason->%s]<-WARNING", playername,tmp);
        SendClientMessageToAll(COLOR_YELLOW, string);
        TogglePlayerControllable(playerid,0);
    }
    else
    {
        afk[playerid] = 0;
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "->%s Is Back On Keyboard<-", playername);
        SendClientMessageToAll(COLOR_YELLOW, string);
        TogglePlayerControllable(playerid,1);
        SetPlayerHealth(playerid,100);
    }
    return 1;
}
Here is strtok function add it any where in script but not in cmds
pawn Код:
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;
}
+REP if i helped so
Reply
#10

Remove cmd from first line, added cmdtext and removed cmd[128]; from third, now it works.
Thankx!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)