Carsurf problem -
Blunt P - 05.02.2012
Hey guys,
im wondering how to script a Anti Carfsurf system. My Problem so far is, that i have no idea, how i can get the ID of the car, by just standing on it.
Do you guys have any ideas?
Re: Carsurf problem -
Twisted_Insane - 05.02.2012
Hey!
First of all, you gotta check if the player is IN the vehicle, little example, used from GetPlayerVehicleID:
pawn Код:
new vehicle;
vehicle = GetPlayerVehicleID(playerid);
if(vehicle > 0)
{
AddVehicleComponent(vehicle, 1010);
}
Also, this page in Wiki might help ya!!
https://sampwiki.blast.hk/wiki/Category:...tions#Vehicles
Re: Carsurf problem -
Babul - 05.02.2012
mh i guess you need this function:
https://sampwiki.blast.hk/wiki/GetPlayerSurfingVehicleID
Re: Carsurf problem -
Twisted_Insane - 05.02.2012
He's probably right, didn't notice this function...Anyways, is it this what you wanted?
AW: Carsurf problem -
Blunt P - 05.02.2012
Quote:
Originally Posted by Babul
|
yeah thats the function i did plan on using, but my problem is, how do i get the ID of the vehicle?
My plan was to make something like this:
IF (GetPlayerSurfingVehicleID == VehicleID)
{
SendClientMessage(playerid,COLOR_RED,"Carsurfing is forbidden!");
}
But my problem is, how the hell can i get the ID from the car, wich the player is surfing on? If he was the driver it wouldnt be any problem, but now the guy would be on the roof....
There lies my problem
Re: Carsurf problem -
milanosie - 05.02.2012
Just set his pos but to Z +5
AW: Carsurf problem -
Blunt P - 05.02.2012
Quote:
Originally Posted by milanosie
Just set his pos but to Z +5
|
I dont want to set any pos oO
I want to get the VehicleID from the car, wich the player is surfing on, without him to enter the car.
Re: Carsurf problem -
milanosie - 05.02.2012
ow, lol readed wrong:
uhm,
pawn Код:
for(new h = 0; h < sizeof(MAX_VEHICLES); h++)
Do something witht that I think
Re: Carsurf problem -
Babul - 05.02.2012
hey, heey!
you should pay attention to
Quote:
Returns The ID of the vehicle...
|
so doing
pawn Код:
new VehID=GetPlayerSurfingVehicleID(playerid);
//and maybe
//SetVehicleHealth(VehID,250);//explodes the vehicle when you jump onto it (only with a driver, else its not synced)
will work
heres a snippet of my /info command:
pawn Код:
new PlayerSurfing=GetVehicleModel(GetPlayerSurfingVehicleID(Player));
if (PlayerSurfing==0)
{
// On Foot
format(string,sizeof(string),"%s - on foot",string);
}
else
{
// Surfing
format(string,sizeof(string),"%s - Surfing %s",string,VehName[PlayerSurfing-400]);
}
as you see, the case 0 at surfing, is an invalid vehicle model id. also the first created vehicle in a server starts at 1 - so you may use the trick with a vehicle id, or even its model id heheh
AW: Carsurf problem -
Blunt P - 05.02.2012
Quote:
Originally Posted by milanosie
ow, lol readed wrong:
uhm,
pawn Код:
for(new h = 0; h < sizeof(MAX_VEHICLES); h++)
Do something witht that I think
|
Quote:
Originally Posted by Babul
hey, heey!
you should pay attention to
so doing
pawn Код:
new VehID=GetPlayerSurfingVehicleID(playerid); //and maybe //SetVehicleHealth(VehID,250);//explodes the vehicle when you jump onto it (only with a driver, else its not synced)
will work
heres a snippet of my /info command:
pawn Код:
new PlayerSurfing=GetVehicleModel(GetPlayerSurfingVehicleID(Player)); if (PlayerSurfing==0) { // On Foot format(string,sizeof(string),"%s - on foot",string); } else { // Surfing format(string,sizeof(string),"%s - Surfing %s",string,VehName[PlayerSurfing-400]); }
as you see, the case 0 at surfing, is an invalid vehicle model id. also the first created vehicle in a server starts at 1 - so you may use the trick with a vehicle id, or even its model id heheh
|
Oh DAMN xD
Now i know why the ID got so horribly weird. Thx i will try that out, if one of my tester is online, then ill try
Код:
GetVehicleModel(GetPlayerSurfingVehicleID(Player)
This was the code i needed if it will work now as expected