Random missions wont work
#1

I've tried to create two random missions, but the samp wiki didnt help me.
Код:
new Float:TruckDirt[][12] =
{
       {-64.6646,-25.0894,3.1172,"Farm","Hops",-176.2634,-277.9630,1.4297,"FleishBerg Brewery",500,1,0},
       {588.0559,844.4221,-42.5385,"Quarry","Coal",-1857.2985,113.2854,15.1172,"Solarin Industries",5000,1,0}
};
On the first line I have 6 times this -> warning 213: tag mismatch and one error -> error 018: initialization data exceeds declared size
IF I changed 12 to 0 I have lot warnings 213....

Anyone can help?
Reply
#2

As this is both floats, integers and strings, you need to use an enum

pawn Код:
enum missionInfo
{
    Float:one,
    Float:two,
    Float:three,
    szOne[ 128 ],
    szTwo[ 128 ],
    szThree[ 128 ],
    Float:four,
    Float:five,
    Float:six,
    iOne,
    iTwo,
    iThree
}
pawn Код:
new TruckDirt[][missionInfo] =
{
    {-64.6646,-25.0894,3.1172,"Farm","Hops",-176.2634,-277.9630,1.4297,"FleishBerg Brewery",500,1,0},
       {588.0559,844.4221,-42.5385,"Quarry","Coal",-1857.2985,113.2854,15.1172,"Solarin Industries",5000,1,0}
};
NOTE: Do not use the exact code I posted, as it's just an example and pretty unefficient.
Reply
#3

Ok that worked.
BUT... As I changed this, now I dk how to add that to the missions system.
I had
Код:
new rand = random(sizeof(TruckDirt));
SetPlayerCheckpoint(playerid, TruckDirt[rand][0], TruckDirt[rand][1], TruckDirt[rand][2], 10);
But now again the warning 213...
Reply
#4

change
pawn Код:
SetPlayerCheckpoint(playerid, TruckDirt[rand][0], TruckDirt[rand][1], TruckDirt[rand][2], 10);
to the enum variables instead:
pawn Код:
SetPlayerCheckpoint(playerid, TruckDirt[rand][one], TruckDirt[rand][two], TruckDirt[rand][three], 10);
Remember that you shouldn't use "one" "two" "three" as that was only the ones I used in my example. You must use the variables you used for the three first floats.
Reply
#5

Thx you very much. It almost works.
I will tell you whats wrong. but this time not with truck loads, but flights.
Код:
enum flightInfo
{
    Float:X1,
    Float:Y1,
    Float:Z1,
    From[128],
    Flnr[128],
    Float:X2,
    Float:Y2,
    Float:Z2,
    To[128],
    Money,
    Score,
}
new Float:Flight[][flightInfo] =
{
    {-1551.1635,-57.9203,14.1440,"San Fierro International Airport","SV-2208",1388.7333,1462.3113,10.8203,"Las Venturas Airport",1000,1},
    {-1551.1635,-57.9203,14.1440,"San Fierro International Airport","SS-2210",2049.6538,-2494.1746,13.5469,"Los Santos Airport",2000,1},
    {-1551.1635,-57.9203,14.1440,"San Fierro International Airport","SM-2213",401.9291,2509.9182,16.4844,"Verdant Meadows Airport",1500,1}
};
At the end of script I have this to make the flights work.
The problem is that it randomise everything. Lets say it says me SF to LV, but the check points appers in SF and LS. I get other flight cash. :/ What did I did wrong again?
Above is trucker missions thats why else if but trucker have same prob.
Код:
else if(gTeam[playerid] == TEAM_PILOT)
    {
       if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 577 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 553 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 519)
       {
            new rand = random(sizeof(Flight));
            if(OnMission[playerid] == 1)
            {
                new obj[256];
                SetPlayerCheckpoint(playerid, Flight[rand][X1], Flight[rand][Y1], Flight[rand][Z1], 10);
                format(obj, sizeof(obj), "Flight number %s from %s to %s",Flight[rand][Flnr], Flight[rand][From], Flight[rand][To]);
                SendClientMessage(playerid, TEAM_PILOT_COLOR, obj);
                SendClientMessage(playerid, TEAM_PILOT_COLOR, "Go to the marked airport");
                OnMission[playerid] = 2;
            }
            else if(OnMission[playerid] == 2)
            {
                SetPlayerCheckpoint(playerid, Flight[rand][X2], Flight[rand][Y2], Flight[rand][Z2], 10);
                SendClientMessage(playerid, TEAM_PILOT_COLOR, "Go to the marked destination airport");
                OnMission[playerid] = 3;
            }
            else if(OnMission[playerid] == 3)
            {
                new reward[256];
                DisablePlayerCheckpoint(playerid);
                OnMission[playerid] = 0;
                format(reward,sizeof(reward), "Delivery completed! You have earned %d$", Flight[rand][Money]);
                SendClientMessage(playerid, TEAM_PILOT_COLOR, reward);
                GivePlayerMoney(playerid, Flight[rand][Money]);
                SetPlayerScore(playerid, GetPlayerScore(playerid)+(Flight[rand][Score]));
            }            
        }        
    }
    return 0;
}
Reply
#6

please help :S
Reply
#7

Quote:
Originally Posted by [LV]Oskars
Посмотреть сообщение
Код:
GivePlayerMoney(playerid, Flight[rand][Money]);
Im guessing to get the correct amount of payout you would need to give a specific mission you completed, not get it to get the cash amount from a random mission?
Reply
#8

Well see...
It randomize everything.
You type the cmd, and you have message - Flight nr.... From SF To LV. The first checkpoint is in SF, but the next one is again in random place (Like i had in the airport in desert). And you also get random payment.(I had payment for flight SF-LS).
But I need that the checkpoint are set correctly and you receive the correct payment.
Hope you got it what I ment to say.
Reply
#9

When the players mission is set, use a "Mission ID" or something like that.

Mission[MAX_PLAYERS];

When they start the mission set Mission[playerid] to a certain Number.

When they pick up the next checkpoints check what mission they are on with the variable. and continue with that.

Simple Effective.. Probably not the most efficient but it should work..
Reply
#10

EG

The mission they start is Mission One.
pawn Код:
Mission[playerid] = 1;
When they enter the Delivery checkpoint
pawn Код:
if(Mission[playerid] == 1)
{
       //Whatever you want to do
}
else if(Mission[playerid] == 2)
{
       //Same
}
else if(Mission[playerid] == 3)
{

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)