RC-XD help.
#1

I have this code:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsKeyJustDown(KEY_SPRINT, newkeys, oldkeys))
    {
        if(GetPlayerVehicleID(playerid == 441))
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid,x,y,z);
            CreateExplosion(x,y,z,7,10.0);
            CreateExplosion(x,y+2,z,7,10.0);
            CreateExplosion(x,y-2,z,7,10.0);
            RemovePlayerFromVehicle(playerid);
            hasrc[playerid] = 0;
            hasbomb[playerid] = 0;
        }
    }
    return 1;
}
But when I press the button, it doesn't blow up? It just continue's moving..

How can I help this?

Thanks.
Reply
#2

Your if statement with GetPlayerVehicle is slightly wrong, it should be:

pawn Код:
if(GetPlayerVehicleID(playerid) == 441)
I would like to point out that you may also be confusing model ID with vehicle ID, this will only work for vehicle ID 441 which is not necessarily your RC-XD vehicle.

You should use GetVehicleModel to return the model ID of the vehicle, for example:

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 441)
Vehicle IDs are basically unique integer values that define each vehicle spawned in the server uniquely, they are assigned in order of when they are spawned.

Model IDs are the unique ID's of the models that the vehicles are using (such as 400 for Landstalker), but do not reference specific instances of those vehicles in the server.
Reply
#3

Thank you SO much! Sorry for the waste of a post, I should have noticed this myself but I'm kinda half asleep! :O

Thank you JaTochNietDan! Repped mate!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)