[Plugin] CHandling - Server control of handlings & per-vehicle handlings
#1

CHandling client & server plugin
CHandling is a client & server sided plugin which allows the server to have control over vehicle handlings. In addition, it modifies the default behaviour of GTA, allowing customized handlings between vehicles of the same model.
This means that you can have 10 Banshees while having each of them drive differently.

The client side is forced to use default handling values when connected to a CHandling-ready server.
Normal players can still play on the server, the plugin just wont have any effect on them.

Client sided plugin has a very simple update checker which can take the players to the download page of the latest release.

This is a test release, not everything is working as it should and some things may require a re-write.
I don't advice to introduce this to your players yet.


CURRENTLY SUPPORTS ONLY CARS! Boats, airplanes or bikes might not work properly, since they are handled differently in the game.

Supported versions
The plugin uses a .ini file for detecting the current version & loading proper memory offsets, the file is fetched from GitHub via libcurl when it doesn't exist, or when there is no matching version in the current file.
That means, that theorethically (unless some significant changes are made to SAMP), players wont need to download anything.

Currently supported versions (client): 0.3.7, 0.3.7 R2, 0.3.7 R3, 0.3.7 R3-1, 0.3.7 R4, 0.3DL R1

Download

Client side requires ASI Loader

Server side


Source code (client side)
Source code (server side)

WIKI (List of natives, descriptions etc)

Example filterscript which may also help testing/trying out



Thanks to
  • Zeex for sampGDK and SubHook
  • DK22Pac for his GTA plugin-sdk that I took some structs from
  • kurta999 for his AMX Native Redirect (taken from YSF)
  • Whitetiger for GetPacketId hook (taken from SAMPACv2)
  • ini for helping with various problems that occured along the way
Reply
#2

Known bugs
  • Some things such as various handling/model flags and suspension lines don't work for players that had the vehicle already streamed in unless it's re-streamed for them
Reply
#3

Been looking for something like this, great job!
Reply
#4

Great release man, i wonder if you could do something similar but for weapon.dat?
Reply
#5

It's possible, I see that MTA did it but as far as I can see it's global, which makes sense. So one modification of weapon property is applied for every player.
I'm not sure about syncing the shoots then, don't know how samp does it under the hood but it probably wouldn't require any changing.

This plugin could evolve into some kind of all-in-one SAMP extension, but for that someone else would need to take it over. I don't have that much time, and I'm not the best at writing clean code when most of the things are experimental memory hacks.
IIRC wheel scaling could be easily added to this plugin as an additional handling option, it could make for some nice rim size modifications etc.
My main idea when creating this plugin was to create some sort of NFS-like upgrade packs for vehicles. You don't neccessarily need to set raw values. You can modify the existing ones, altering the handling.
In example, you can lower the mass by a percentage value and lower the drag multiplier, making the car go faster:
Code:
new Float:val;
GetVehicleHandling(vehicleid, HANDL_FMASS, val);
SetVehicleHandling(vehicleid, HANDL_FMASS, val*0.9); // 90% of previous mass
GetVehicleHandling(vehicleid, HANDL_FTURNMASS, val);
SetVehicleHandling(vehicleid, HANDL_FTURNMASS, val*0.9);
GetVehicleHandling(vehicleid, HANDL_FDRAGMULTIPLIER, val);
SetVehicleHandling(vehicleid, HANDL_FDRAGMULTIPLIER, val*0.9);
It's worth noting that subsequent calls to SetVehicleHandling wont create additional packets, since the modifications are all sent in a single packet at the next ProcessTick.
Reply
#6

Nice
Reply
#7

Good job, i was going to look at it as something good for stopping people who mess around with vehicle's original handling after reading "The client side is forced to use default handling values when connected to a CHandling-ready server." But then again it requires the asi loader file on the client side which not many would download. Thanks for your efforts tho!
Reply
#8

I'm using the testing filterscript and I keep getting "Failed to set handling value, check if it's correct". Can someone help?
Reply
#9

Make sure you input float values with a dot and not a period (0.1 etc)
Also, there are value-correctness checks, you can see the proper value ranges here: Handling attributes

Some attribites such as the anim group cannot be set.
Reply
#10

Quote:
Originally Posted by dotSILENT
View Post
Make sure you input float values with a dot and not a period (0.1 etc)
Also, there are value-correctness checks, you can see the proper value ranges here: Handling attributes

Some attribites such as the anim group cannot be set.
I am inputting everything correctly and yet it doesn't work. And yes, I am taking in mind the value-correctness checks, already read through the whole wiki on github.

Here's a pic of what I'm inputting:
https://ibb.co/q9WgfwN

Edit: forgot to mention in case you ask, I am trying to change the engine acceleration flag.
Reply
#11

That's really weird, I just tested it on both linux & windows, vehicles created with both CreateVehicle and AddStaticVehicle worked fine.
The current value shown (0.0) is not valid, and it appears like the plugin couldn't initialize properly and didn't call
Code:
HandlingDefault::Initialize()
Check your logs, are there any errors? The plugin needs to hook a few things in the server in order to work properly, it's possible that other plugins like YSF or SampAC are affecting this. Although I just checked with YSF and there's no problem with loading it either before or after chandlingsvr.
What's your plugins line in server.cfg? Are you running the server on linux or windows? What version of the server are you running? Are other vehicles, or attributes in the same vehicle working fine?

This definitely looks like some initialization problem.

Edit: however if IsPlayerUsingCHandling() returns true, then the RakNet hook must be working, so that'd mean the initialization was successful, which makes it even more weird.
Reply
#12

Quote:
Originally Posted by dotSILENT
View Post
That's really weird, I just tested it on both linux & windows, vehicles created with both CreateVehicle and AddStaticVehicle worked fine.
The current value shown (0.0) is not valid, and it appears like the plugin couldn't initialize properly and didn't call
Code:
HandlingDefault::Initialize()
Check your logs, are there any errors? The plugin needs to hook a few things in the server in order to work properly, it's possible that other plugins like YSF or SampAC are affecting this. Although I just checked with YSF and there's no problem with loading it either before or after chandlingsvr.
What's your plugins line in server.cfg? Are you running the server on linux or windows? What version of the server are you running? Are other vehicles, or attributes in the same vehicle working fine?

This definitely looks like some initialization problem.

Edit: however if IsPlayerUsingCHandling() returns true, then the RakNet hook must be working, so that'd mean the initialization was successful, which makes it even more weird.
Yes IsPlayerUsingCHandling() does return true. I tried other vehicles (tried only cars) and none is working, I tried all attributes - all giving the same error.

Running it on windows with only these plugins: "sscanf streamer sampp_server chandlingsvr".

About errors - definitely no erros. The logs are as following:
Code:
[17:38:21]   Loaded.
[17:38:21]  Loading plugin: sampp_server
[17:38:21] [SA-MP+] Loaded
[17:38:21]   Loaded.
[17:38:21]  Loading plugin: chandlingsvr
[17:38:23] [###] CHandlingSvr v1.0-dev by .silent loaded [###]
[17:38:23]   Loaded.
[17:38:23]  Loaded 4 plugins.
Edit
Perhaps it's the sampp plugin and its asi? Will try and then will update the post.
Reply
#13

It's very likely, however afaik it's not hooking the server's raknet but creating it's own instance so I don't know what would be the problem. Is it even being updated? I think it's outdated for a few years already unless someone updated it. I'm running crashdetect, YSF, sscanf, mysql, streamer and pawncmd together with this plugin without any problems.

The hooking procedure starts when the gamemode is being loaded, thats where errors should be thrown (if any)
You can send me the dll for that sampp plugin @ pm if you want me to check it out.
Reply
#14

Quote:
Originally Posted by dotSILENT
View Post
It's very likely, however afaik it's not hooking the server's raknet but creating it's own instance so I don't know what would be the problem. Is it even being updated? I think it's outdated for a few years already unless someone updated it. I'm running crashdetect, YSF, sscanf, mysql, streamer and pawncmd together with this plugin without any problems.

The hooking procedure starts when the gamemode is being loaded, thats where errors should be thrown (if any)
You can send me the dll for that sampp plugin @ pm if you want me to check it out.
I tested it now and I can confirm that it is due to the sampp plugin. It's working fine now, without it. Then I put it back and it started giving me the same bugs.
Reply
#15

I tried this last night. Its pretty fun to play around with!

But i found an odd issue. I keep getting a sampgdk warning when using this. It appears to happen when CallRemoteFunction is used inside the gamemode or filterscripts. Example...
Code:
[sampgdk:warning] Index mismatch for OnServerTimeUpdate (-10058 != -10057)
[sampgdk:warning] Index mismatch for Speedo_SetVehicleFuel (-10071 != -10070)
Something like this. Them are just two of the ones that get called by callremotefunction.

Also i need to load the plugin before any other plugins, otherwise it will not load.
Reply
#16

That's caused by sampgdk, although I don't know why would it happen with CallRemoteFunction. I just tested it and called a remote function from the filterscript and nothing happened. Only index mismatches I'm getting are for OnPlayerStatsAndWeaponUpdate coming from YSF, probably because I'm using some older version.

I'm not that experienced with sampgdk, but does it happen for every CallRemoteFunction you do, or just these 2?
One thing I noticed is that the indexes are off by just one.

As for the issue with loading the plugins, I'd like to know the list of plugins you are loading. There must be some that conflict with this one, I have no problem with loading it in any place despite using YSF, streamer and a few others.


Update:
That earlier problem with SAMP+ plugin causing CHandling to stop working is caused entirely by SAMP+, I think it's using a very old version of sampgdk which messes up the natives when loaded before other plugins. And since CHandling uses IsValidVehicle() native, it returns false and GetVehicleHandling* thinks the vehicle doesn't exist. It also messed up the streamer plugin, objects attached to vehicles stopped working.
Reply
#17

Quote:
Originally Posted by dotSILENT
View Post
That's caused by sampgdk, although I don't know why would it happen with CallRemoteFunction. I just tested it and called a remote function from the filterscript and nothing happened. Only index mismatches I'm getting are for OnPlayerStatsAndWeaponUpdate coming from YSF, probably because I'm using some older version.

I'm not that experienced with sampgdk, but does it happen for every CallRemoteFunction you do, or just these 2?
One thing I noticed is that the indexes are off by just one.

As for the issue with loading the plugins, I'd like to know the list of plugins you are loading. There must be some that conflict with this one, I have no problem with loading it in any place despite using YSF, streamer and a few others.
This seems to be a issue with the sky plugin. As long as i load the chandling before sky it works, but the sampgdk warnings show up. And it only appears to be a select few CallRemoteFunction calls that are affected. And they do not call the remote functions either.

Ill do some more debugging on my end, i will make a issue on github if i find any more info out.

Also if it makes any difference, i am on windows 10.
Reply
#18

I know why it's not working when you put it after SKY.
It's because SKY uses the exact same GetPacketId hook (which I actually took from Whitetiger's sampACv2). But SKY hooks the function directly in Load(), which overwrites the first 5 bytes with a JMP instruction, causing my FindPattern to fail. That's why I don't install hooks until the first AmxLoad call, so other plugins can use FindPattern under Load(), but SKY is not doing that.
I'll have to workarounnd that somehow, probably increasing the FindPattern signature and ignoring the first 5 bytes, if that will be possible.
As for these sampgdk warnings I'll have to test it out.

Update
I made a small commit (here) which addresses the hook-conflict with SKY (and any other plugin that would hook GetPacketID under Load()). It falls back to an alternate, longer pattern prefixed with a JMP instruction so it should find the correct function even if it was hooked already. Tested it on both windows and linux and it seems to work properly.
Haven't made a release as it's just a tiny change and SKY plugin is also kinda outdated. If someone really needs this then you can compile it yourself, or just load the plugin before SKY as it also does the job.
Reply
#19

Excellent effort & great idea.. but the clientside installation requirement makes this fall short from being one of the most useful plugins I've seen. I guess its "as good as it gets" for now
Reply
#20

There is no other way to do it unless it's done by Kalcor, and I wouldn't count on that.
In my opinion, client sided modifications (ehm..SAMP Addon, but I'll give a very very bad stare at the guy who made it for not making it open source, which is one of the reasons I'm never ever touching it, especially that afaik it comes from Russia) are the only future for SA:MP considering the frequency of updates. Of course it's not safe to run compiled code from untrusted sources, which is why every modification of such sort should be open source (again, I look at you SAMP Addon)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)