[Include] Anti Car Surfing
#1

This include adds 4 things, 3 functions and a callback.

Код:
stock SetVehicleSurfable(modelid, bool: set);
stock SetPlayerSurfImmunity(playerid, bool: immunity);
stock GetPlayerSurfImmunity(playerid);
forward OnPlayerCarSurf(playerid, vehicleid);
You can prevent car surfing on all vehicles or for certain models using SetVehicleSurfable function. By default, all vehicle models (including boats) are not allowed to car surf on.

OnPlayerCarSurf will get called if you add the public to your script and you can do whatever you want to the player from there, if you don't add it to your script players will get slapped when they car surf.

Also you can define SURF_MIN_SPEED before including antisurf. By default if a vehicle's speed is lower than 25, surfers won't get slapped or callback won't get called. You can change that using SURF_MIN_SPEED.

[NEW] You can give immunity to players now using SetPlayerSurfImmunity. If they've been given immunity, when they car surf nothing will happen. You can get a players immunity state using GetPlayerSurfImmunity.

Few Examples:

Код:
#include <antisurf>

public OnPlayerCarSurf(playerid, vehicleid)
{
	// take $250 from the player
	GivePlayerMoney(playerid, -250);
	SendClientMessage(playerid, 0xFF0000FF, "Car surfing is not allowed on this server, $250 taken.");
	return 1;
}
Код:
#include <antisurf>

public OnPlayerCarSurf(playerid, vehicleid)
{
	// stop the vehicle player surfed on
	SetVehicleVelocity(vehicleid, 0.0, 0.0, 0.0);
	return 1;
}
Код:
#define 	SURF_MIN_SPEED 		120.0
#include 	<antisurf>

public OnPlayerCarSurf(playerid, vehicleid)
{
	// this callback only gets called when a player surfs on a 120+ speed vehicle because of SURF_MIN_SPEED.
	// kill the player because vehicle the player was surfing on was too fast
	SetPlayerHealth(playerid, -1.0);
	SendClientMessage(playerid, -1, "You fell from the vehicle.");
	return 1;
}
Changelog:

23.03.2015:
- Added SetPlayerSurfImmunity and GetPlayerSurfImmunity. Thanks Abagail for your suggestion.

Reply


Messages In This Thread
Anti Car Surfing - by rootcause - 22.03.2015, 16:36
Re: Anti Car Surfing - by Naruto_Emilio - 22.03.2015, 19:15
Re: Anti Car Surfing - by Abagail - 22.03.2015, 19:24
Re: Anti Car Surfing - by Mokless - 22.03.2015, 19:29
Re: Anti Car Surfing - by rootcause - 23.03.2015, 20:06
Re: Anti Car Surfing - by thaKing - 23.03.2015, 20:24
Re: Anti Car Surfing - by SHFaCeBook - 02.04.2015, 18:03
Re: Anti Car Surfing - by FILIX - 14.07.2015, 17:09
Re: Anti Car Surfing - by FILIX - 14.07.2015, 17:33
Re: Anti Car Surfing - by KayJ - 11.08.2015, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)