Random coords
#1

Hello!

im trying to convert and change my old delivery code.
There is 12 coords that i want to split up on 4 teams on this cmd, the coords should be random selected as this code does right now, but only from 3 specific coords for each team (hope you understand what i mean)

case 0-2 is for GetPlayerTeam(playerid) == 0)
case 3-5 is for GetPlayerTeam(playerid) == 1)
case 6-8 is for GetPlayerTeam(playerid) == 2)
case 9-11 is for GetPlayerTeam(playerid) == 3)
the 12th case can be removed.

I have no idea how to split this up, the players for now gets one of all these coords randomly, the point is to only get 1 of 3 of the teams specific coords. And im sure the code can be made mush better.

pawn Code:
COMMAND:deliver(playerid, params[])
{
        if(IsPlayerConnected(playerid))
        {
                if(IsPlayerInAnyVehicle(playerid))
                {
                    if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 433)
                    {
                                if(enrep[playerid] == 0 && enload[playerid] == 0)
                                {
                                    if(ccargado[playerid] == 1)
                                    {
                                        new lugdent = random(12);
                                        enrep[playerid] = 1;
                                        switch (lugdent)
                                        {
                                            case 0:
                                            {
                                                SetPlayerCheckpoint(playerid,2338.7712,32.0935,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of magazines to jazz magazines");
                                            }
                                            case 1:
                                            {
                                                SetPlayerCheckpoint(playerid,2338.8330,-44.6022,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery with products to Raimi Realty");
                                            }
                                            case 2:
                                            {
                                                SetPlayerCheckpoint(playerid,2339.0125,-67.0500,26.3359,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of hardware to Bubґs");
                                            }
                                            case 3:
                                            {
                                                SetPlayerCheckpoint(playerid,2314.4478,-93.3005,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery to the General Store");
                                            }
                                            case 4:
                                            {
                                                SetPlayerCheckpoint(playerid,2299.0232,-70.7920,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of books to the DMV School");
                                            }
                                            case 5:
                                            {
                                                SetPlayerCheckpoint(playerid,2298.9321,-10.3696,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of bankchecks to the bank");
                                            }
                                            case 6:
                                            {
                                                SetPlayerCheckpoint(playerid,2276.4290,46.8699,26.4844,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of alcohol to the bar");
                                            }
                                            case 7:
                                            {
                                                SetPlayerCheckpoint(playerid,1231.3864,192.6526,19.5547,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Roadhunters");
                                            }
                                            case 8:
                                            {
                                                SetPlayerCheckpoint(playerid,844.5975,-599.1318,18.4219,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Street Cruisers");
                                            }
                                            case 9:
                                            {
                                                SetPlayerCheckpoint(playerid,2362.4163,240.6807,26.6089,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tools and spareparts to the mechanic garage");
                                            }
                                            case 10:
                                            {
                                                SetPlayerCheckpoint(playerid,1394.3412,376.3297,19.7703,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tires to the Derby arena");
                                            }
                                            case 11:
                                            {
                                                SetPlayerCheckpoint(playerid,2270.4766,-84.9801,26.5111,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a deliver of materials to the Palomino PDP");
                                            }
                                            case 12:
                                            {
                                                SetPlayerCheckpoint(playerid,1334.6967,286.4982,19.5615,4);
                                                SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a deliver of soft drinks to the Sprunk Factory");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        SendClientMessage(playerid, COLOR_RED, "Load your truck first, type /loadtruck to load it!");
                                        return 1;
                                    }
                                }
                                else
                                {
                                    SendClientMessage(playerid, COLOR_RED, "Your mission is cancelled!");
                                    DisablePlayerCheckpoint(playerid);
                                    enrep[playerid] = 0;
                                    enload[playerid] = 0;
                                    ccargado[playerid] = 0;
                                    return 1;
                                }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_RED, "You have to be the driver!");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "You have to be in a delivery truck!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "You have to be in a Truck!");
                    return 1;
                }
        return 1;
    }
Reply
#2

pawn Code:
COMMAND:deliver(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 433)
        {
            if(enrep[playerid] == 0 && enload[playerid] == 0)
            {
                if(ccargado[playerid] == 1)
                {
                    new lugdent;
                    if(GetPlayerTeam(playerid) == 0) lugdent = random(3);
                    else if(GetPlayerTeam(playerid) == 1) lugdent = 2+random(3);
                    else if(GetPlayerTeam(playerid) == 2) lugdent = 5+random(3);
                    else if(GetPlayerTeam(playerid) == 3) lugdent = 8+random(3);
                    enrep[playerid] = 1;
                    switch (lugdent)
                    {
                        case 1:
                        {
                            SetPlayerCheckpoint(playerid,2338.7712,32.0935,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of magazines to jazz magazines");
                        }
                        case 2:
                        {
                            SetPlayerCheckpoint(playerid,2338.8330,-44.6022,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery with products to Raimi Realty");
                        }
                        case 3:
                        {
                            SetPlayerCheckpoint(playerid,2339.0125,-67.0500,26.3359,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of hardware to Bubґs");
                        }
                        case 4:
                        {
                            SetPlayerCheckpoint(playerid,2314.4478,-93.3005,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery to the General Store");
                        }
                        case 5:
                        {
                            SetPlayerCheckpoint(playerid,2299.0232,-70.7920,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of books to the DMV School");
                        }
                        case 6:
                        {
                            SetPlayerCheckpoint(playerid,2298.9321,-10.3696,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of bankchecks to the bank");
                        }
                        case 7:
                        {
                            SetPlayerCheckpoint(playerid,2276.4290,46.8699,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of alcohol to the bar");
                        }
                        case 8:
                        {
                            SetPlayerCheckpoint(playerid,1231.3864,192.6526,19.5547,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Roadhunters");
                        }
                        case 9:
                        {
                            SetPlayerCheckpoint(playerid,844.5975,-599.1318,18.4219,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Street Cruisers");
                        }
                        case 10:
                        {
                            SetPlayerCheckpoint(playerid,2362.4163,240.6807,26.6089,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tools and spareparts to the mechanic garage");
                        }
                        case 11:
                        {
                            SetPlayerCheckpoint(playerid,1394.3412,376.3297,19.7703,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tires to the Derby arena");
                        }
                        case 12:
                        {
                            SetPlayerCheckpoint(playerid,2270.4766,-84.9801,26.5111,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a deliver of materials to the Palomino PDP");
                        }
                        default: return 1;
                    }
                }
                else return SendClientMessage(playerid, COLOR_RED, "Load your truck first, type /loadtruck to load it!");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your mission is cancelled!");
                DisablePlayerCheckpoint(playerid);
                enrep[playerid] = 0;
                enload[playerid] = 0;
                ccargado[playerid] = 0;
                return 1;
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "You have to be the driver!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You have to be in a delivery truck!");
}
Reply
#3

You should make an array of coordinates for each team. Like:

pawn Code:
new team1coords[3];

team1coords[3]
{
Coordinate1,
Coordinate2,
Coordinate3,
}

new team2coords[3]

team2coords[3];
{
Coordinate1,
Coordinate2,
Coordinate3,
}

new team3coords[3];

team3coords[3]
{
Coordinate1,
Coordinate2,
Coordinate3,
}

new team4coords[3];

team4coords[3]
{
Coordinate1,
Coordinate2,
Coordinate3,
}
Reply
#4

Quote:
Originally Posted by Pharrel
View Post
pawn Code:
COMMAND:deliver(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 433)
        {
            if(enrep[playerid] == 0 && enload[playerid] == 0)
            {
                if(ccargado[playerid] == 1)
                {
                    new lugdent;
                    if(GetPlayerTeam(playerid) == 0) lugdent = random(3);
                    else if(GetPlayerTeam(playerid) == 1) lugdent = 2+random(3);
                    else if(GetPlayerTeam(playerid) == 2) lugdent = 5+random(3);
                    else if(GetPlayerTeam(playerid) == 3) lugdent = 8+random(3);
                    enrep[playerid] = 1;
                    switch (lugdent)
                    {
                        case 1:
                        {
                            SetPlayerCheckpoint(playerid,2338.7712,32.0935,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of magazines to jazz magazines");
                        }
                        case 2:
                        {
                            SetPlayerCheckpoint(playerid,2338.8330,-44.6022,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery with products to Raimi Realty");
                        }
                        case 3:
                        {
                            SetPlayerCheckpoint(playerid,2339.0125,-67.0500,26.3359,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of hardware to Bubґs");
                        }
                        case 4:
                        {
                            SetPlayerCheckpoint(playerid,2314.4478,-93.3005,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery to the General Store");
                        }
                        case 5:
                        {
                            SetPlayerCheckpoint(playerid,2299.0232,-70.7920,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of books to the DMV School");
                        }
                        case 6:
                        {
                            SetPlayerCheckpoint(playerid,2298.9321,-10.3696,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of bankchecks to the bank");
                        }
                        case 7:
                        {
                            SetPlayerCheckpoint(playerid,2276.4290,46.8699,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of alcohol to the bar");
                        }
                        case 8:
                        {
                            SetPlayerCheckpoint(playerid,1231.3864,192.6526,19.5547,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Roadhunters");
                        }
                        case 9:
                        {
                            SetPlayerCheckpoint(playerid,844.5975,-599.1318,18.4219,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Street Cruisers");
                        }
                        case 10:
                        {
                            SetPlayerCheckpoint(playerid,2362.4163,240.6807,26.6089,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tools and spareparts to the mechanic garage");
                        }
                        case 11:
                        {
                            SetPlayerCheckpoint(playerid,1394.3412,376.3297,19.7703,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tires to the Derby arena");
                        }
                        case 12:
                        {
                            SetPlayerCheckpoint(playerid,2270.4766,-84.9801,26.5111,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a deliver of materials to the Palomino PDP");
                        }
                        default: return 1;
                    }
                }
                else return SendClientMessage(playerid, COLOR_RED, "Load your truck first, type /loadtruck to load it!");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your mission is cancelled!");
                DisablePlayerCheckpoint(playerid);
                enrep[playerid] = 0;
                enload[playerid] = 0;
                ccargado[playerid] = 0;
                return 1;
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "You have to be the driver!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You have to be in a delivery truck!");
}
Thanks again! but i get a warning on the command
pawn Code:
warning 209: function "cmd_deliver" should return a value
Reply
#5

pawn Code:
COMMAND:deliver(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 433)
        {
            if(enrep[playerid] == 0 && enload[playerid] == 0)
            {
                if(ccargado[playerid] == 1)
                {
                    new lugdent;
                    if(GetPlayerTeam(playerid) == 0) lugdent = random(3);
                    else if(GetPlayerTeam(playerid) == 1) lugdent = 2+random(3);
                    else if(GetPlayerTeam(playerid) == 2) lugdent = 5+random(3);
                    else if(GetPlayerTeam(playerid) == 3) lugdent = 8+random(3);
                    enrep[playerid] = 1;
                    switch (lugdent)
                    {
                        case 1:
                        {
                            SetPlayerCheckpoint(playerid,2338.7712,32.0935,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of magazines to jazz magazines");
                        }
                        case 2:
                        {
                            SetPlayerCheckpoint(playerid,2338.8330,-44.6022,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery with products to Raimi Realty");
                        }
                        case 3:
                        {
                            SetPlayerCheckpoint(playerid,2339.0125,-67.0500,26.3359,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of hardware to Bubґs");
                        }
                        case 4:
                        {
                            SetPlayerCheckpoint(playerid,2314.4478,-93.3005,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery to the General Store");
                        }
                        case 5:
                        {
                            SetPlayerCheckpoint(playerid,2299.0232,-70.7920,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of books to the DMV School");
                        }
                        case 6:
                        {
                            SetPlayerCheckpoint(playerid,2298.9321,-10.3696,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of bankchecks to the bank");
                        }
                        case 7:
                        {
                            SetPlayerCheckpoint(playerid,2276.4290,46.8699,26.4844,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of alcohol to the bar");
                        }
                        case 8:
                        {
                            SetPlayerCheckpoint(playerid,1231.3864,192.6526,19.5547,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Roadhunters");
                        }
                        case 9:
                        {
                            SetPlayerCheckpoint(playerid,844.5975,-599.1318,18.4219,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of car parts to Palomino Street Cruisers");
                        }
                        case 10:
                        {
                            SetPlayerCheckpoint(playerid,2362.4163,240.6807,26.6089,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tools and spareparts to the mechanic garage");
                        }
                        case 11:
                        {
                            SetPlayerCheckpoint(playerid,1394.3412,376.3297,19.7703,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a delivery of tires to the Derby arena");
                        }
                        case 12:
                        {
                            SetPlayerCheckpoint(playerid,2270.4766,-84.9801,26.5111,4);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have a deliver of materials to the Palomino PDP");
                        }
                        default: return 1;
                    }
                }
                else return SendClientMessage(playerid, COLOR_RED, "Load your truck first, type /loadtruck to load it!");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your mission is cancelled!");
                DisablePlayerCheckpoint(playerid);
                enrep[playerid] = 0;
                enload[playerid] = 0;
                ccargado[playerid] = 0;
                return 1;
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "You have to be the driver!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You have to be in a delivery truck!");
    return 1;
}
Reply
#6

I think something like this would be more suited:
pawn Code:
#define MAX_DELOCATIONS    12
enum DELIVER_INFO{Float:deX,Float:deY,Float:deZ,deTeam}
new gDeliverCoords[MAX_DELOCATIONS][DELIVER_INFO];

GetDeliverId(playerid)
{
    new deid,playerteam;
    playerteam=GetPlayerTeam(playerid);
    do deid=random(MAX_DELOCATIONS);
    while (gDeliverCoords[deid][deTeam]!=playerteam);
    return deid;
}
I'll let you think for the rest of the code.
Reply
#7

Quote:
Originally Posted by decondelite
View Post
I think something like this would be more suited:
pawn Code:
#define MAX_DELOCATIONS    12
enum DELIVER_INFO{Float:deX,Float:deY,Float:deZ,deTeam}
new gDeliverCoords[MAX_DELOCATIONS][DELIVER_INFO];

GetDeliverId(playerid)
{
    new deid,playerteam;
    playerteam=GetPlayerTeam(playerid);
    do deid=random(MAX_DELOCATIONS);
    while (gDeliverCoords[deid][deTeam]!=playerteam);
    return deid;
}
I'll let you think for the rest of the code.
If you gave me som more info about these stuffs i might be able to use it
pawn Code:
gDeliverCoords
do deid
deTeam
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)