Carsurf problem
#1

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?
Reply
#2

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
Reply
#3

mh i guess you need this function:
https://sampwiki.blast.hk/wiki/GetPlayerSurfingVehicleID
Reply
#4

He's probably right, didn't notice this function...Anyways, is it this what you wanted?
Reply
#5

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
Reply
#6

Just set his pos but to Z +5
Reply
#7

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.
Reply
#8

ow, lol readed wrong:

uhm,

pawn Код:
for(new h = 0; h < sizeof(MAX_VEHICLES); h++)
Do something witht that I think
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)