Help me on this command please
#1

Hey, can anyone tell me why this code doesnt Work, the command is for making "A materials" to less "D materials" but when i type /refine a 100, it will give me like 10206454 D materials (just an example) please help me, here is the code.

pawn Код:
if(strcmp(cmd, "/refine", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pJob] != 2 && !(PlayerInfo[playerid][pAdmin] & ADMIN_ACCESS))
            {
                SendClientMessage(playerid, 0xAFAFAFAA, "   You are not a  Material Handler!");
                return 1;
            }
            tmp = strtok(cmdtext,idx);
            if(strlen(tmp))
            {
                if(!strcmp(tmp, "a", true))
                {
                    tmp = strtok(cmdtext,idx);
                    new result = strval(tmp);
                    if(result < 100 || result > PlayerInfo[playerid][pMats])
                    {
                        format(string, 256, "USAGE: /refine a [%d A mats]", PlayerInfo[playerid][pMats]);
                        SendClientMessage(playerid, 0xBFC0C2FF, string);
                        return 1;
                    }
                    PlayerInfo[playerid][pMats] = PlayerInfo[playerid][pMats] - result;
                    new Float:dmats = floatround(result / 20.0, 0);
                    PlayerInfo[playerid][pMatsd] = dmats + PlayerInfo[playerid][pMatsd];
                    format(string, 256, "you have created %d D materials from %d A materials.", dmats, result);
                    SendClientMessage(playerid, 0xAFAFAFAA, string);
                    return 1;
                }
            }
            SendClientMessage(playerid, 0xBFC0C2FF, "USAGE: /refine [a/b/c] [ammount]");
            return 1;
        }
    }
Reply
#2

Why don't you use ZCMD + sscanf?

It would be more easy help you.
Reply
#3

Use a code like this
pawn Код:
PlayerInfo[playerid][pMatsd] += (your value);
Your value will be added to the last one, this is your question I think ?
Reply
#4

I still have the same problem
Reply
#5

Nevermind, i fixed it by myself
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)