Weird error
#1

Hey guys,

I got a problem with entering vehicle.
I've made a stock, that holds the vehicle ID's of the slower cars of the game.
pawn Код:
stock PlayerInLangzaamAuto(playerid)
{
    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
    {
        case 405, 406, 408, 410, 413, 414, 418, 422, 423, 436, 455, 458, 466, 474, 479, 482, 483, 499, 507, 516, 524, 526, 527, 531, 540, 543, 546, 547, 551, 572, 585, 605: return 1;
    }
    return 1;
}
When i enter any vehicle, that isn't between those ID's, i get the message i only should get when i enter those cars above. Anyone could take a look what i did wrong?

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    if(PlayerInLangzaamAuto(playerid))
    {
            SendClientMessage(playerid, COLOR_LIGHTGREEN, "Slow Car");
            return 1;
    }
        return 1;
}
~Wesley
Reply
#2

You are returning 1 even if he doesn't have that vehicle.

fixed:
pawn Код:
stock PlayerInLangzaamAuto(playerid)
{
    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
    {
        case 405, 406, 408, 410, 413, 414, 418, 422, 423, 436, 455, 458, 466, 474, 479, 482, 483, 499, 507, 516, 524, 526, 527, 531, 540, 543, 546, 547, 551, 572, 585, 605: return 1;
    }
    return 0; // here.
}

EDIT: I wouldn't mind knowing if it worked...
Reply
#3

To bad this didnt work
When i enter a car right now (with the return 0, then you just enter the vehicle and nothing happens
Reply
#4

That's beause OnPlayerEnterVehicle appears when the player is going to enter the car, not when he's inside the car.
GetPlayerVehicleID returns the vehicle id only if the player is in the car.

Use these:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    if(IsVehicleLangzaamAuto(vehicleid))
    {
            SendClientMessage(playerid, COLOR_LIGHTGREEN, "Slow Car");
            return 1;
    }
        return 1;
}
stock IsVehicleLangzaamAuto(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 405, 406, 408, 410, 413, 414, 418, 422, 423, 436, 455, 458, 466, 474, 479, 482, 483, 499, 507, 516, 524, 526, 527, 531, 540, 543, 546, 547, 551, 572, 585, 605: return 1;
    }
    return 0; // here.
}
Reply
#5

Still the same problem, when i enter an infernus i just get "Slow Car"
Reply
#6

replace the function to:
pawn Код:
stock IsVehicleLangzaamAuto(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 405, 406, 408, 410, 413, 414, 418, 422, 423, 436, 455, 458, 466, 474, 479, 482, 483, 499, 507, 516, 524, 526, 527, 531, 540, 543, 546, 547, 551, 572, 585, 605: return 1;
        default: return 0;
    }
    return 0; // here.
}
Check if you've compiled the script and actually viewing the updated script on your server, because my last code where should to work.
Reply
#7

That one did work: Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)