PDA

View Full Version : Kicking low score's from helicopters: Need help


CrucixTM
25/01/2010, 01:47 PM
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (GetPlayerVehicleID(playerid) == 497)
{
if (GetPlayerScore(playerid) < 5 )
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
}
}
if (GetPlayerVehicleID(playerid) == 487)
{
if (GetPlayerScore(playerid) < 5 )
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
}
}
if (GetPlayerVehicleID(playerid) == 563)
{
if (GetPlayerScore(playerid) < 5 )
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
}
}
if (GetPlayerVehicleID(playerid) == 548)
{
if (GetPlayerScore(playerid) < 5 )
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
}
}


return 1;
}


Doesn't seem to work. I'm quite not very good at this, so no wonder. Basicly, I want you to be kicked from helicopters when you enter them(the ID's are 548, 563, 487, 497) if your score is below 5.

Any ideas?(;

Niixie
25/01/2010, 01:53 PM
Yes, i have one.
-Gimmi a sec and ill make it for you and explain it as good as i can :)

CrucixTM
25/01/2010, 01:58 PM
Oh, I luv ya.

Btw your dialogue box tutorial was win! ;)

Niixie
25/01/2010, 02:08 PM
Hehe thank you :)

-Here, this will teach you how to do that thing :)

http://helipaste.pastebin.com/f7b1b7e28
UNTESTED

Djiango
25/01/2010, 02:19 PM
You should use OnPlayerStateChange instead. As OnPlayerEnterVehicle is called when a player presses "ENTER". So you can't use RemovePlayerFromVehicle, becuase he's not sitting in the vehicle yet.

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new veh = GetPlayerVehicleID(playerid);
if(veh == 497 || veh == 487 || veh == 563 || veh == 548)
{
if(GetPlayerScore(playerid) < 5)
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
return 1;
}
}
}
return 1;
}

CrucixTM
25/01/2010, 02:34 PM
Oh Thanks man!

Almost perfect - but not quite.

Because it detecs he is in a vehicle the second I press "F" to enter, so it kicks me while entering, and then I don't get kicked.

So, is there any way to delay the RemovePlayerFromVehicle?

Niixie
25/01/2010, 02:35 PM
Well, if you can give me some time ill make it with that function. im with my GF right now

CrucixTM
25/01/2010, 02:37 PM
Ill test the state change one. :) Thanks guys, and np Niixie.

Celson
25/01/2010, 02:46 PM
|∞|-цппσĵσ-|∞|'s code is good. But I get the feeling that CrucixTM is actually trying to check the vehicle model not the vehicle id. So use this code if you wanted to do that.


public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehid = GetPlayerVehicleID(playerid);
new vehmodel = GetVehicleModel(vehid);
if(vehmodel == 497 || vehmodel == 487 || vehmodel == 563 || vehmodel == 548)
{
if(GetPlayerScore(playerid) < 5)
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Removed from Vehicle - Score not high enough",4000,5);
SendClientMessage(playerid, COLOR_RED , "Kicked from vehicle - Score too low. Read /scoreinfo for help.");
return 1;
}
}
}
return 1;
}

CrucixTM
25/01/2010, 02:49 PM
Well I don't know what I want to check, if its Model or ID.

The list on sa-mp wiki said "Vehicle ID's" (I think) So I've been assuming the ID is the code for that type of vehicle, and the model had something to do with its appearance. Imma try yours, Celson.

Celson
25/01/2010, 02:55 PM
Just let me know how it goes.

CrucixTM
25/01/2010, 02:56 PM
Celson, you're the hero of the day, yours works like a charm. :mrgreen:

Thanks to all of you guys for contributing :)

Mike Garber
25/01/2010, 03:12 PM
Well I don't know what I want to check, if its Model or ID.

The list on sa-mp wiki said "Vehicle ID's" (I think) So I've been assuming the ID is the code for that type of vehicle, and the model had something to do with its appearance. Imma try yours, Celson.


A ModelID, is the Vehicle Model, aka Sultan, Elegy, Admiral. Those always stay the same.
A VehicleID is the vehicle number, the first car you add in your script will be VehicleID 1, second will be Vehicle ID 2 etc.

So you want to check model, Not ID.

Celson
25/01/2010, 03:19 PM
Well I don't know what I want to check, if its Model or ID.

The list on sa-mp wiki said "Vehicle ID's" (I think) So I've been assuming the ID is the code for that type of vehicle, and the model had something to do with its appearance. Imma try yours, Celson.


A ModelID, is the Vehicle Model, aka Sultan, Elegy, Admiral. Those always stay the same.
A VehicleID is the vehicle number, the first car you add in your script will be VehicleID 1, second will be Vehicle ID 2 etc.

So you want to check model, Not ID.


Actually with vehicle ids. It starts at 0 not 1. So your first vehicle is vehicle id 0. I'm pretty sure it's like that with all integers.

On_Top_Non_Stop
25/01/2010, 04:26 PM
Well I don't know what I want to check, if its Model or ID.

The list on sa-mp wiki said "Vehicle ID's" (I think) So I've been assuming the ID is the code for that type of vehicle, and the model had something to do with its appearance. Imma try yours, Celson.


A ModelID, is the Vehicle Model, aka Sultan, Elegy, Admiral. Those always stay the same.
A VehicleID is the vehicle number, the first car you add in your script will be VehicleID 1, second will be Vehicle ID 2 etc.

So you want to check model, Not ID.


Actually with vehicle ids. It starts at 0 not 1. So your first vehicle is vehicle id 0. I'm pretty sure it's like that with all integers.


Vehicle ID's start at 1 :)

Djiango
25/01/2010, 04:28 PM
Thanks for correcting my code Celson. It was of course meant for vehicle models, and not vehicle id's. :-[

Facuarg
25/01/2010, 07:46 PM
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 520) // Hydra
{
if(GetPlayerScore(playerid) < 150)
{
SendClientMessage(playerid, rojo_03,"*You can't enter, you need at least 150 points.);
RemovePlayerFromVehicle(playerid);
}
else
{
SendClientMessage(playerid, verde_00,"* You do have at least 150 points. You now can drive the plane.");
}
}
}
}
}


Hope it helps you. It's what I'm using in my gamemode.
Bye bye.
Facu.

Sydcul
04/01/2013, 05:31 PM
Well I don't know what I want to check, if its Model or ID.

The list on sa-mp wiki said "Vehicle ID's" (I think) So I've been assuming the ID is the code for that type of vehicle, and the model had something to do with its appearance. Imma try yours, Celson.

This is not exactly a bump, just to clarify for people who ****** this or something.

If i have 5 vehicle spawns in my OnGameModeInit, the first car is vehicle ID 0, the third is id 2, etc. If i have a Infernus, it is Model ID 411. So it's different. The Vehicle ID's on the wiki page are actually Model ID's.