[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
#2

Nice, I guess?
Reply
#3

screenshots?
Reply
#4

Yo, sounds nice, but can we get some screenies?
Reply
#5

People ask for screenshot man!

Do it for us! Make a screenshot!
Reply
#6

Just uploaded a screenshot.
Reply
#7

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Just uploaded a screenshot.
Ohh..thanks!

So..i see this kind of speedometer somewhere..i think it's just desing..
Reply
#8

You might have seen this speedometer on some trucking server, which used my gamemode.

I'm splitting up my gamemode in several different filterscripts, as I need some of them for my next gamemode(s).
I don't want to re-create all the code everytime when I launch another gamemode.
Reply
#9

COOL!
Reply
#10

Good Job! Thank you.
Reply
#11

Very nice, good job.
Reply
#12

Get out of the house your system is, many people would be happy for him.
Reply
#13

Cool, This SpeedoMeter Dont Have Bug

Thanks
Reply
#14

Looks good. I'll test it.
Reply
#15

NEW UPDATE:

- added speedcamera's to the script

Use the command "/createcamera <max_speed>" to create a new camera.
Use the command "/delcamera" while you stand near a camera to delete it.

Example:
/createcamera 120

This would create a speedcamera which gives one star to anyone who drives past it faster than 120 kph.


NOTE: the script also needs zcmd and dutils.
Reply
#16

I have not run out of fuel in the tank.
Reply
#17

GJ man ...
I'll test
Reply
#18

Nice! Yeah this works really cool,its in the ppc trucking script! The fuel has no bugs or anything
Reply
#19

Quote:
Originally Posted by Skyny10
View Post
I have not run out of fuel in the tank.
Only 1 fuel was consumed every half a second, that's 2 fuel per second.
When you entered a vehicle, it had 5000 fuel.

This allows for 5000/2 = 2500 seconds of constant driving before you run out of fuel.
2500/60 = 41.666 minutes.

This has been changed now to 2400 fuel.
2400/2 = 1200 seconds (or 1200/60 = 20 minutes) before your tank is empty.



BTW: there's a new update.

Added: option to disable the shadows for the speedometer and fuel textdraws.
Added: /fuel command (allows RCON admins to refuel their vehicle free of charge).

Added: extra remote functions to check if a player has logged in properly.
Like in my GM, a variable is set to True when the player entered his password correctly.
If the player didn't enter the correct password (or didn't enter anything) but pressed F6 to enter commands in the chatbox, that variable is set to False, blocking any commands.

Added: extra remote functions to check the player's admin-level.

If those extra functions aren't used in your admin-script or gamemode, RCON admin status is checked automatically.
And the LoggedIn status is always valid if the remote function isn't used.
Reply
#20

Nice job, keep it up!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)