Bugged cmd
#1

The same line comes when I try to use the cmd (Marked it in the script)
pawn Код:
if(strcmp(cmd, "/loadmats", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new tmpcar = GetPlayerVehicleID(playerid);
            new compcost = 30;
            if(IsPlayerInRangeOfPoint(playerid, 20, -2687.8723,1413.9987,7.1016))
            {
                if(IsATruck(tmpcar) || IsATrailer(tmpcar))
                {
                    if(PlayerHaul[tmpcar][pMaterials] < PlayerHaul[tmpcar][pCapasity])
                    {
                        new amount;
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SCM(playerid, COLOR_GRAD1, "USAGE: /loadmats [amount]");
                            return 1;
                        }
                        amount = strval(tmp);
                        if(amount < 1 || amount > 100) { SCM(playerid, COLOR_GREY, "   Can't buy less then 1 material or more then 100!"); return 1; }
                        new check = PlayerHaul[tmpcar][pMaterials] + amount;
                        if(check > PlayerHaul[tmpcar][pCapasity])
                        {
                            format(string, sizeof(string), "   You went over the Truck Carry Limit of %d, you currently carry %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pMaterials]);
                            SCM(playerid, COLOR_GREY, string);
                            return 1;
                        }
                        new cost = amount*compcost;
                        if(GetPlayerMoney(playerid) >= cost)
                        {
                            PlayerHaul[tmpcar][pMaterials] = amount;
                            format(string, sizeof(string), "Materials: %d/%d.", PlayerHaul[tmpcar][pMaterials],PlayerHaul[tmpcar][pCapasity]);
                            SCM(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "You bought %d materials for $%d.", amount,cost);
                            SCM(playerid, TEAM_GROVE_COLOR, string);
                            SafeGivePlayerMoney(playerid,-cost);
                            return 1;
                        }
                        else
                        {
                            format(string, sizeof(string), "You cant afford %d Materials at $%d!", amount,cost);
                            SCM(playerid, TEAM_GROVE_COLOR, string);
                            return 1;
                        }
                    }
                    else
                    {
                        /*----->*/  SCM(playerid, TEAM_GROVE_COLOR,"A Truck can only carry 1-100, if you want to carry up too 1000 you will need a Trailer.");  //This line comes when I try to use the cmd
                            return 1;
                    }
                }
                else
                {
                    SCM(playerid, TEAM_GROVE_COLOR, "This Vehicle does not deliver materials.");
                    return 1;
                }
            }
            else
            {
                SCM(playerid, COLOR_GREY, "You are not in materials place.");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

Maybe this PlayerHaul[tmpcar][pCapasity] should be PlayerHaul[tmpcar][pCapacity] ?
Reply
#3

Thats not the problem, it was just misspelled when it was made
Reply
#4

I've located the problem. The commented one doesnt work.

pawn Код:
/*for(new i=0; i < MAX_VEHICLES; i++)
    {
        if(IsATruck(i))
        {
            PlayerHaul[i][pCapacity] = 100;
        }
        else if(IsATrailer(i))
        {
            PlayerHaul[i][pCapacity] = 1000;
        }
    }*/

    for(new i=0; i < MAX_VEHICLES; i++)
    {
        PlayerHaul[i][pCapacity] = 100;
    }
How can i make it so the commented one works?
Reply
#5

show us your IsATruck(vehid) // or vehicule id or some thing like this

and your IsATrailer(vehid) or vehicule id
Reply
#6

Here are both IsATruck and IsATrailer
pawn Код:
public IsATruck(carid)
{
    new m = GetVehicleModel(carid);
    if(m == 433 || m == 403 || m == 406 || m == 482 || m == 440 || m == 408 || m == 414 || m == 443 || m == 456 || m == 455 || m == 498 || m == 499 || m == 514 || m == 515 || m == 609 || m == 413 || m == 428)
    {
        return 1;
    }
    return 0;
}

public IsATrailer(carid)
{
    new m = GetVehicleModel(carid);
    if(m == 435 || m == 450 || m == 591)
    {
        return 1;
    }
    return 0;
}
Reply
#7

change || by &&
Reply
#8

Wont that check if the model is x and x and x and since it cant be all at the same time it will fail?
Reply
#9

yes i have'nt any explication but i have fixed that probleme with changing || by && ^^
Reply
#10

Quote:
Originally Posted by Golf
Посмотреть сообщение
yes i have'nt any explication but i have fixed that probleme with changing || by && ^^
Ok I'll try ^^
Reply


Forum Jump:


Users browsing this thread: