[FilterScript] PPC Speedometer
#1

I've just completed my speedometer filterscript and has some nice features.
It was part of my gamemode (PPC_Trucking), but has been adapted to work standalone.

It has:
- speedometer
- fuel gauge
- refuel-stations (gas-stations): to refuel your vehicle, stand near a gas-station pickup and honk the horn
- speedcamera's

Also, 2 bugs have been fixed in this script (but not yet in the gamemode):
- the first created refuel-station didn't work (you couldn't refuel your vehicle at this gas-station)
- every player inside a car consumed 1 fuel every half a second (so with 4 players inside the same car, the vehicle would consume fuel 4 times faster), now it only consumes fuel for the driver

The filterscript uses Incognito's streamer for the pickups and 3DText labels, so you need it for this script to work.
https://sampforum.blast.hk/showthread.php?tid=102865
It also uses sscanf (I'm still using an older version, as I still use Samp 0.3c):
https://sampforum.blast.hk/showthread.php?tid=120356
And zcmd is also required:
https://sampforum.blast.hk/showthread.php?tid=91354



To install this filterscript:
- just copy the file to your filterscript's folder and add "PPC_Speedo" it to your server.cfg file on the "filterscripts" line:
Код:
filterscripts gl_realtime gl_actions PPC_Speedo
To create speedcamera's, login to RCON and use this command to create a new speedcamera:
/createcamera <max_speed>

Replace <max_speed> by the required speed for this camera.
Example:
/createcamera 90
This creates a speedcamera which gives you one star on your wanted level if you drive past it faster than 90kph.

/delcamera can be used to delete the camera near your location.


IMPORTANT:
All camera-data is saved in the file "scriptfiles\PPC_Speedometer\Cameras.ini". The location of the file and filename can be adjusted if required at the top of the script.
You must add the directory "PPC_Speedometer" to your scriptfiles folder, or your server will crash when you try to create a camera.
You can also change:
pawn Код:
#define CameraFile      "PPC_Speedometer/Cameras.ini"
Into:
pawn Код:
#define CameraFile      "Cameras.ini"
And recompile, then you don't need the directory.



Also added is an admin-command: /fuel.
This will allow RCON admins to refuel their vehicle free of charge.



There are also a few functions that are something special, which allow cross-script communication:
- Speedo_GetVehicleFuel(vehicleid)
- Speedo_SetVehicleFuel(vehicleid, fuel)
- Speedo_GetPlayerSpeed(playerid)

These functions can be called from other scripts using "CallRemoteFunction".
They allow you to:
- get the fuel of the given vehicle
- set the fuel of the given vehicle
- get the player's speed



Also, there are a few functions that you need to copy and modify to your gamemode or other filterscripts if you use server-sided money.
The filterscript normally has no access to your account-data that your gamemode might hold, but these functions allow the speedometer script to get data from your gamemode if you copy them to your gamemode.
They are near the bottom of the filterscript.

If you don't copy and edit them, the script will automatically use client-sided money.
pawn Код:
// This function is used to get the player's money
forward EXT_GetPlayerMoney(playerid);
public EXT_GetPlayerMoney(playerid)
{
    return APlayerData[playerid][PlayerMoney];
}

// This function is used to get the player's money
forward EXT_GivePlayerMoney(playerid, Money);
public EXT_GivePlayerMoney(playerid, Money)
{
    // Add the given money to the player's account
    APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + Money;

    // Return that the function had success (another script holds the player's money on the server-side)
    return 1;
}

// This function is used to get the player's admin-level
forward EXT_GetPlayerAdminLevel(playerid);
public EXT_GetPlayerAdminLevel(playerid)
{
    return APlayerData[playerid][AdminLevel];
}

// This function is used to determine if the player has logged in (he succesfully entered his password)
forward EXT_IsPlayerLoggedIn(playerid);
public EXT_IsPlayerLoggedIn(playerid)
{
    if (APlayerData[playerid][LoggedIn] == true)
        return 1; // The player has logged in succesfully
    else
        return -1; // The player hasn't logged in (yet)
}
The inner workings of these functions are pretty much self-explanatory.
You might need to edit the location of your data (pData[playerid][Money] for example, instead of APlayerData[playerid][PlayerMoney]).

All commands are also edited to include remote checks to see if a player has logged in properly and if he has admin-status.
Logging in properly: a player must enter his password before he's allowed to use any command.
Of course, your gamemode or admin-script needs to set a variable for this.
See my gamemode (PPC_Trucking) to see how it works.

If the admin-status isn't remotely checked (you didn't copy/adapt the remote functions), RCON admin status is checked automatically.
Also, the logged-in status is skipped if the remote functions aren't used and the player can use the commands freely (if they're logged in as RCON admin).


The script also has support for my housing script, which will be released soon (still adding new stuff and testing the whole script).
House-owned vehicles won't get refuelled automatically when they respawn, as the housing script will manage the fuel remotely.
If you don't use the housing script, nothing will be bugged, as it's designed to work properly when used standalone.

The housing system will also work standalone and doesn't depend on this speedometer script.
It will only call some remote functions in this script to manage a vehicle's fuel (getting the fuel for saving the vehicle's fuel and setting the fuel when the vehicle is loaded).
Only the fuel will be saved as 0 when this script isn't used.



Screenshot (at a gas-station):


Screenshot (speeding near a speedcamera which is set to catch you above 120kph):


Download it here:
http://users.telenet.be/vge/download...PPC_Speedo.pwn
Reply


Messages In This Thread
PPC Speedometer - by PowerPC603 - 09.09.2011, 21:11
Re: PPC Speedometer - by FireCat - 09.09.2011, 21:26
Re: PPC Speedometer - by Gforcez - 09.09.2011, 21:30
Re: PPC Speedometer - by X3nZ - 09.09.2011, 21:39
Re: PPC Speedometer - by Rock_Ro - 09.09.2011, 21:57
Re: PPC Speedometer - by PowerPC603 - 09.09.2011, 22:00
Re: PPC Speedometer - by Rock_Ro - 09.09.2011, 22:10
Re: PPC Speedometer - by PowerPC603 - 09.09.2011, 22:48
Re: PPC Speedometer - by Haydn - 10.09.2011, 02:00
Re: PPC Speedometer - by Skyny10 - 10.09.2011, 16:27
Re: PPC Speedometer - by Darnell - 10.09.2011, 16:30
Re: PPC Speedometer - by Skyny10 - 10.09.2011, 16:49
Re: PPC Speedometer - by Assasins_Creed - 10.09.2011, 16:59
Re: PPC Speedometer - by Anzhelov - 10.09.2011, 17:32
Re: PPC Speedometer - by PowerPC603 - 10.09.2011, 21:14
Re: PPC Speedometer - by Skyny10 - 11.09.2011, 09:23
Re: PPC Speedometer - by rigucci - 11.09.2011, 17:27
Re: PPC Speedometer - by sherlock - 11.09.2011, 18:11
Re: PPC Speedometer - by PowerPC603 - 11.09.2011, 21:39
Re: PPC Speedometer - by wolfcock - 12.09.2011, 07:42
Re: PPC Speedometer - by PowerPC603 - 13.09.2011, 10:27
Re: PPC Speedometer - by [Aka]Dragonu - 14.09.2011, 12:48
Re: PPC Speedometer - by PowerPC603 - 15.09.2011, 08:28
Re: PPC Speedometer - by |_ⒾⓇⓄN_ⒹⓄG_| - 15.09.2011, 08:30
Re : PPC Speedometer - by Varkoll_ - 15.09.2011, 20:06
Re: PPC Speedometer - by Bramblez - 16.09.2011, 16:35
Re: PPC Speedometer - by Lookin - 17.09.2011, 04:51
Re: PPC Speedometer - by Dredd - 12.10.2011, 20:45
Re: PPC Speedometer - by PowerPC603 - 12.10.2011, 22:15
Re: PPC Speedometer - by --tiny-- - 13.10.2011, 19:42
Re: PPC Speedometer - by REAL1337 - 22.11.2013, 10:20
Re: PPC Speedometer - by Justinclaveria123 - 23.10.2014, 05:57
Re: PPC Speedometer - by LeXuZ - 23.10.2014, 06:52
AW: PPC Speedometer - by Flori - 23.10.2014, 09:50
Re: PPC Speedometer - by BobiMk - 23.10.2014, 10:19

Forum Jump:


Users browsing this thread: 1 Guest(s)