/getpizza
#1

I have made this command for someone who has the job to /getpizza.

Its supposed to loop through all of the SPAWNED houses and set the player's checkpoint to that house.

Spawned houses go up one everytime a house file loads.

For some reason, when I do /getpizza, it will say Unknown Command if all the if the if( statements are correct. However, if I get off the bike, move away from the point, or don't have a job it will display the error message

Here you go:
pawn Код:
command(getpizza, playerid, params[])
{
    if(Player[playerid][Authenticated] == 1)
    {
        if(Jobs[Player[playerid][Job]][JobType] == 8 || Jobs[Player[playerid][Job2]][JobType] == 8)
        {
            if(IsPlayerInVehicle(playerid, PizzaBike1) || IsPlayerInVehicle(playerid, PizzaBike2) || IsPlayerInVehicle(playerid, PizzaBike3) || IsPlayerInVehicle(playerid, PizzaBike4) || IsPlayerInVehicle(playerid, PizzaBike5) || IsPlayerInVehicle(playerid, PizzaBike6) || IsPlayerInVehicle(playerid, PizzaBike7) || IsPlayerInVehicle(playerid, PizzaBike8))
            {
                if(IsPlayerInRangeOfPoint(playerid, 5, Jobs[Player[playerid][Job]][JobMiscLocationOneX], Jobs[Player[playerid][Job]][JobMiscLocationOneY], Jobs[Player[playerid][Job]][JobMiscLocationOneZ]) || IsPlayerInRangeOfPoint(playerid, 5.0, Jobs[Player[playerid][Job2]][JobMiscLocationOneX], Jobs[Player[playerid][Job2]][JobMiscLocationOneY], Jobs[Player[playerid][Job2]][JobMiscLocationOneZ]))
                {
                    new rand = random(SpawnedHouses);

                    Player[playerid][Checkpoint] = 1;

                    if(Houses[rand][hInteriorID] == 0)
                    {
                        SetPlayerCheckpoint(playerid, Houses[rand][hExteriorX], Houses[rand][hExteriorY], Houses[rand][hExteriorZ], 5.0);

                        Player[playerid][PizzaTimer] = 1;
                    }
                    else
                    {
                        SetPlayerCheckpoint(playerid, Houses[1][hExteriorX], Houses[1][hExteriorY], Houses[1][hExteriorZ], 5.0);
                    }
                    SendClientMessage(playerid, WHITE, "You have three minutes to deliver the pizza to the house marked on your minimap!");
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "You are not near the pizza pickup!");//These show if called in the script
                }
            }
            else
            {
                SendClientMessage(playerid, WHITE, "You are not on a pizza bike!");//These show if called in the script
            }
        }
        else
        {
            SendClientMessage(playerid, WHITE, "You are not a Pizza Boy!");//These show if called in the script
        }
    }
    return 1;
}
REP+
Reply
#2

pawn Код:
command(getpizza, playerid, params[])
{
    if(Player[playerid][Authenticated] == 1)
    {
        if(Jobs[Player[playerid][Job]][JobType] != 8 && Jobs[Player[playerid][Job2]][JobType] != 8) return SendClientMessage(playerid, WHITE, "You are not a Pizza Boy!");
        new vehid = GetPlayerVehicleID(playerid);
        switch(vehid)
        {
            case    PizzaBike1, PizzaBike2, PizzaBike3, PizzaBike4,
                    PizzaBike5, PizzaBike6, PizzaBike7, PizzaBike8:
            {
                new jid = Player[playerid][Job];
                if(!IsPlayerInRangeOfPoint(playerid, 5, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ])
                {
                    jid = Player[playerid][Job2];
                    if(!IsPlayerInRangeOfPoint(playerid, 5.0, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ]))
                        return SendClientMessage(playerid, WHITE, "You are not near the pizza pickup!");
                }
                new rand = random(SpawnedHouses), attempts = 0;
                Player[playerid][Checkpoint] = 1;
                while(Houses[rand][hInteriorID])
                {
                    if(attempts >= 50) return SendClientMessage(playerid, WHITE, "Could not find a house.");
                    //Security countermeasure to make sure this loop doesn't hang your server.
                    rand = random(SpawnedHouses);
                    attempts++;
                }
                SetPlayerCheckpoint(playerid, Houses[rand][hExteriorX], Houses[rand][hExteriorY], Houses[rand][hExteriorZ], 5.0);
                Player[playerid][PizzaTimer] = 1;
                SendClientMessage(playerid, WHITE, "You have three minutes to deliver the pizza to the house marked on your minimap!");
            }
            default: SendClientMessage(playerid, WHITE, "You are not on a pizza bike!");
        }
    }
    return 1;
}
pawn Код:
if(Houses[rand][hInteriorID] == 0)
Give this a shot.

pawn Код:
if(Houses[rand][hInteriorID] == 0)
Is that meant to be 'if(Houses[rand][hInteriorID] == 0)' or 'if(Houses[rand][hInteriorID] != 0)'?
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
command(getpizza, playerid, params[])
{
    if(Player[playerid][Authenticated] == 1)
    {
        if(Jobs[Player[playerid][Job]][JobType] != 8 && Jobs[Player[playerid][Job2]][JobType] != 8) return SendClientMessage(playerid, WHITE, "You are not a Pizza Boy!");
        new vehid = GetPlayerVehicleID(playerid);
        switch(vehid)
        {
            case    PizzaBike1, PizzaBike2, PizzaBike3, PizzaBike4,
                    PizzaBike5, PizzaBike6, PizzaBike7, PizzaBike8:
            {
                new jid = Player[playerid][Job];
                if(!IsPlayerInRangeOfPoint(playerid, 5, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ])
                {
                    jid = Player[playerid][Job2];
                    if(!IsPlayerInRangeOfPoint(playerid, 5.0, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ]))
                        return SendClientMessage(playerid, WHITE, "You are not near the pizza pickup!");
                }
                new rand = random(SpawnedHouses), attempts = 0;
                Player[playerid][Checkpoint] = 1;
                while(Houses[rand][hInteriorID])
                {
                    if(attempts >= 50) return SendClientMessage(playerid, WHITE, "Could not find a house.");
                    //Security countermeasure to make sure this loop doesn't hang your server.
                    rand = random(SpawnedHouses);
                    attempts++;
                }
                SetPlayerCheckpoint(playerid, Houses[rand][hExteriorX], Houses[rand][hExteriorY], Houses[rand][hExteriorZ], 5.0);
                Player[playerid][PizzaTimer] = 1;
                SendClientMessage(playerid, WHITE, "You have three minutes to deliver the pizza to the house marked on your minimap!");
            }
            default: SendClientMessage(playerid, WHITE, "You are not on a pizza bike!");
        }
    }
    return 1;
}
pawn Код:
if(Houses[rand][hInteriorID] == 0)
Give this a shot.

pawn Код:
if(Houses[rand][hInteriorID] == 0)
Is that meant to be 'if(Houses[rand][hInteriorID] == 0)' or 'if(Houses[rand][hInteriorID] != 0)'?
I already confirmed that its supposed to be if == and not !=. I suspect it has something to do with the IsPlayerInRangeOfPoint line.
Reply
#4

Okay then, the above code should work in that case.
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Okay then, the above code should work in that case.
pawn Код:
error 008: must be a constant expression; assumed zero
on

pawn Код:
case    PizzaBike1, PizzaBike2, PizzaBike3, PizzaBike4, // This line
                    PizzaBike5, PizzaBike6, PizzaBike7, PizzaBike8:
Reply
#6

Quote:
Originally Posted by BornHuman
Посмотреть сообщение
pawn Код:
error 008: must be a constant expression; assumed zero
on

pawn Код:
case    PizzaBike1, PizzaBike2, PizzaBike3, PizzaBike4, // This line
                    PizzaBike5, PizzaBike6, PizzaBike7, PizzaBike8:
I think Thres meant the pizza bike vehicle ids, which is located on the server
Reply
#7

Oh yeah wtf was I trying to do... lol...
You can't use variables in a switch case, sorry I didn't notice that.

pawn Код:
command(getpizza, playerid, params[])
{
    if(Player[playerid][Authenticated] == 1)
    {
        new jid = Player[playerid][Job], jid2 = Player[playerid][Job2];
        if(Jobs[jid][JobType] != 8 && Jobs[jid2][JobType] != 8) return SendClientMessage(playerid, WHITE, "You are not a Pizza Boy!");
        new v = GetPlayerVehicleID(playerid);
        if(v == PizzaBike1 || v == PizzaBike2 || v == PizzaBike3 || v == PizzaBike4 || v == PizzaBike5 || v == PizzaBike6 || v == PizzaBike7 || v == PizzaBike8)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 5, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ]))
            {
                if(!IsPlayerInRangeOfPoint(playerid, 5.0, Jobs[jid2][JobMiscLocationOneX], Jobs[jid2][JobMiscLocationOneY], Jobs[jid2][JobMiscLocationOneZ]))
                    return SendClientMessage(playerid, WHITE, "You are not near the pizza pickup!");
            }
            new rand = random(SpawnedHouses), attempts = 0;
            Player[playerid][Checkpoint] = 1;
            while(Houses[rand][hInteriorID])
            {
                if(attempts >= 50) return SendClientMessage(playerid, WHITE, "Could not find a house.");
                //Security countermeasure to make sure this loop doesn't hang your server.
                rand = random(SpawnedHouses);
                attempts++;
            }
            SetPlayerCheckpoint(playerid, Houses[rand][hExteriorX], Houses[rand][hExteriorY], Houses[rand][hExteriorZ], 5.0);
            Player[playerid][PizzaTimer] = 1;
            SendClientMessage(playerid, WHITE, "You have three minutes to deliver the pizza to the house marked on your minimap!");
        }
        else SendClientMessage(playerid, WHITE, "You are not on a pizza bike!");
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Oh yeah wtf was I trying to do... lol...
You can't use variables in a switch case, sorry I didn't notice that.

pawn Код:
command(getpizza, playerid, params[])
{
    if(Player[playerid][Authenticated] == 1)
    {
        new jid = Player[playerid][Job], jid2 = Player[playerid][Job2];
        if(Jobs[jid][JobType] != 8 && Jobs[jid2][JobType] != 8) return SendClientMessage(playerid, WHITE, "You are not a Pizza Boy!");
        new v = GetPlayerVehicleID(playerid);
        if(v == PizzaBike1 || v == PizzaBike2 || v == PizzaBike3 || v == PizzaBike4 || v == PizzaBike5 || v == PizzaBike6 || v == PizzaBike7 || v == PizzaBike8)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 5, Jobs[jid][JobMiscLocationOneX], Jobs[jid][JobMiscLocationOneY], Jobs[jid][JobMiscLocationOneZ]))
            {
                if(!IsPlayerInRangeOfPoint(playerid, 5.0, Jobs[jid2][JobMiscLocationOneX], Jobs[jid2][JobMiscLocationOneY], Jobs[jid2][JobMiscLocationOneZ]))
                    return SendClientMessage(playerid, WHITE, "You are not near the pizza pickup!");
            }
            new rand = random(SpawnedHouses), attempts = 0;
            Player[playerid][Checkpoint] = 1;
            while(Houses[rand][hInteriorID])
            {
                if(attempts >= 50) return SendClientMessage(playerid, WHITE, "Could not find a house.");
                //Security countermeasure to make sure this loop doesn't hang your server.
                rand = random(SpawnedHouses);
                attempts++;
            }
            SetPlayerCheckpoint(playerid, Houses[rand][hExteriorX], Houses[rand][hExteriorY], Houses[rand][hExteriorZ], 5.0);
            Player[playerid][PizzaTimer] = 1;
            SendClientMessage(playerid, WHITE, "You have three minutes to deliver the pizza to the house marked on your minimap!");
        }
        else SendClientMessage(playerid, WHITE, "You are not on a pizza bike!");
    }
    return 1;
}
Compiles, still says unknown command
Reply
#9

Is there anything in your server console?
Reply
#10

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Is there anything in your server console?
Nope, nothing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)