Mission help.
#1

Hey guys, i'v been wondering what i'v done wrong, i'v tryed pretty much everything. When you enter the vehicle it will say "Press MMB to start a drug mission", then when you press MMB it doesn't work. i'v tryed using If(IsPlayerInVehicle), GetPlayerVehicleID so i'm not really sure.

Cheers in advance.

code:
pawn Код:
new Float:VanUnloads[][14] = {
    {2474.0447,1124.0911,10.8203},
    {2511.2468,1665.0664,10.8203},
    {2042.2836,2141.9180,10.8203},
    {2055.6897,2199.2947,10.8203},
    {1981.7634,2077.4819,10.8203},
    {1373.0298,1968.3542,11.2573},
    {1342.2938,1988.8014,10.8127},
    {1307.9276,2084.5015,10.8203},
    {1297.5133,2082.0200,10.8127},
    {1145.5381,2036.6021,10.8203},
    {948.7875,2073.2620,10.8203},
    {766.6767,2057.3159,6.7109},
    {587.8662,1642.3119,6.9922},
    {541.5541,1557.5353,1.0000}
};
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SUBMISSION)
    {
        if(IsPlayerInVehicle(playerid, 5))
        {
            new rand = random(sizeof(VanUnloads));
            SetPlayerRaceCheckpoint(playerid, 0,VanUnloads[rand][0], VanUnloads[rand][1],VanUnloads[rand][2],0,0,0,10);
            printf("Played %s has started a van mission",GetName(playerid));
        }
    }
    return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 5 || vehicleid == 7 || vehicleid == 8 ||vehicleid == 4 || vehicleid == 6)
    {
        GameTextForPlayer(playerid, "To start drug missions press ~g~MMB",5000,5);
    }
    return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
    new string[100];
    new earnamount = random(5000-2000)+2000;
    GivePlayerMoney(playerid, earnamount);
    format(string,sizeof(string),"You have earnt $%d for delievering the drugs. press MMB to start another mission.",earnamount);
    SendClientMessage(playerid, COLOR_YELLOW,string);
    DisablePlayerRaceCheckpoint(playerid);
    drugmissions[playerid]++;
    return 1;
}
Reply
#2

pawn Код:
if(newkeys & KEY_SUBMISSION)
Try that. Also the second dimension on the 2d array only needs to be 3 cells big not 14. First dimension is 14.
You could leave both them without specifying a size and the compiler will calculate the size at compile time. Then you can add more co-ords w/o worrying about size.
Reply
#3

Quote:
Originally Posted by iggy1
Посмотреть сообщение
pawn Код:
if(newkeys & KEY_SUBMISSION)
Try that. Also the second dimension on the 2d array only needs to be 3 cells big not 14. First dimension is 14.
You could leave both them without specifying a size and the compiler will calculate the size at compile time. Then you can add more co-ords w/o worrying about size.
ahk cheers for the tip.

i tested the code and it didn't work.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInVehicle(playerid, 5))
        {
            new rand = random(sizeof(VanUnloads));
            SetPlayerRaceCheckpoint(playerid, 0,VanUnloads[rand][0], VanUnloads[rand][1],VanUnloads[rand][2],0,0,0,10);
            printf("Played %s has started a van mission",GetName(playerid));
        }
    }
    return 1;
}
Is that how it should be?
Reply
#4

The code works its something to do with your checkpoint or vehicle id. You might not have scripted it right to get the results you want this works, just tested does print to the console window.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            printf("Played %s has started a van mission");
        }
    }
    return 1;
}
Reply
#5

Yeh i'v done something wrong, that doesn't print in the console. The missions use to work awhile ago but i tested them recently and they just seemed not to work. Any ideas on what could cause them to not function?
Reply
#6

Quote:
Originally Posted by Hayden_Bruin
Посмотреть сообщение
Yeh i'v done something wrong, that doesn't print in the console.
It does.
Quote:
Originally Posted by iggys log
[14:07:44] Played has started a van mission
[14:07:45] Played has started a van mission
[14:07:45] Played has started a van mission
[14:07:45] Played has started a van mission
[14:07:45] Played has started a van mission
[14:07:46] Played has started a van mission
[14:07:46] Played has started a van mission
[14:07:47] Played has started a van mission
[14:07:47] Played has started a van mission
[14:07:48] Played has started a van mission
I'm guessing its your vehicleid thats messing you up. Try doing it with IsPlayerInAnyVehicle and see if it works, if it does you know what the problem is.
Reply
#7

Strange, i tryed testing it when the player is in any vehicle and no vehicle. when i used no vehicle it printed fine in the console but when i added the vehicle in it didn't print. So i'm guessing some other function has a part is not allowing it to work.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            printf("Played %s has started a van mission"); //didn't print
        }
    }
    return 1;
}
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SUBMISSION)
    {
        printf("Played %s has started a van mission"); // did print.
    }
    return 1;
}
Reply
#8

Well you have to be in a vehicle to use KEY_SUBMISSIONS so the vehicle check was redundant
Try using vehicle models. Or instead of using constants ie, "vehicleid == 5" use variables as vehicleids.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)