[Include] OnPlayerUseVending.inc
#1

What is this?
This include calls the function OnPlayerUseVending when a player uses a vending machine (Sprunk or other).
When a player presses F, a timer gets started. If the player has the vending animation (1660) applied, he must be using a vend machine.
This is my first include, so it might not be the best optimized include.

Use
This include can be used for creating a health anticheat or changing the ammount of money a player pays when he uses a vending machine. Eg:
Код:
#include <OnPlayerUseVending>

[...]

OnPlayerUseVending(playerid){
    realHealth[playerid] += 35;
    if(realHealth[playerid]>100) realHealth[playerid] = 100;
    realMoney[playerid] -= 200;
    GameTextForPlayer(playerid, "~r~-$200", 3000, 1);
}
It's highly unlikely that a hacker will press F, apply the vending animation and then update his health to +35.

This can also be used to get more money from the player when he uses a vending machine.

Download
Solidfiles - http://www.solidfiles.com/d/3750704fdb/
Github - https://raw.github.com/i0ni/vending....er/vending.inc
Pastebin - http://pastebin.com/suFe3mKn

Changelog
0.1 - first version
0.1a - fixed a hook bug.

Bugs
None found. Report if you find any bugs.
I used this for like 2 months on my server (100-200 players online) and I found no bugs with it.
No need to detect the position of sprunk machines. I checked all the threads that contained the positions of the sprunk machines before making this include and all of them had some sprunk machines left out. Also, I'm using some custom sprunk machines and I'm applying the sprunk drinking animation to detect those.
Works ok on 0.3e, 0.3x. It will most likely also work with the future versions of SA:MP.

More
[Include] vending.inc - this does the same thing as my include, it also detect the positions of the vending machines and allows the creating of custom sprunk machines. I didn't test that, but it may be better for you if you need something more. At the time at creating my include this didn't exist.
Reply
#2

Quote:
Originally Posted by im
Посмотреть сообщение
What is this?
This include calls the function OnPlayerUseVending when a player uses a vending machine (Sprunk or other).
When a player presses F, this a timer gets started. If the player has the vending animation (1660) applied, he must be using a vend machine.
This is my first include, so it might not be the best optimized include.

Use
This include can be used for creating a health anticheat. Eg:
Код:
#include <OnPlayerUseVending>

[...]

OnPlayerUseVending(playerid){
    realHealth[playerid] += 35;
    if(realHealth[playerid]>100) realHealth[playerid] = 100;
}
It's highly unlikely that a hacker will press F, apply the vending animation and then update his health to +35.

Download
Pastebin - http://pastebin.com/EsvA7miL
SolidFiles - http://www.solidfiles.com/d/a6a3170d62/

Changelog
0.1 - first version

Next
- I will be adding the positions of all the vending machines so OnPlayerUseVending will only be called if the player is near a vending machine. I have a list of all the vending machines, but some are missing. I will try to find out the positions of all the vending machines and then update the include.


Bugs
None found. Report if you find any bugs.
You should make it check if he's near a vending machine...
Because what if I applyanimation to the player, and he presses that button?
Reply
#3

Why would you apply a vending animation to a player?
Reply
#4

Quote:
Originally Posted by im
Посмотреть сообщение
Why would you apply a vending animation to a player?
I don't know... Simulating him drinking something at a coffee shop? RP stuff.
Reply
#5

Instead of checking for position, hook ApplyAnimation and if it's set, don't call the callback.
Reply
#6

Quote:
Originally Posted by FireCat
Посмотреть сообщение
I don't know... Simulating him drinking something at a coffee shop? RP stuff.
The eating and drinking animations are different.
The VEND_USE animation is the one where the player pushes a button and then drinks something.
You can use drink / eat animations without the vend_use animation.
Reply
#7

well, i think is useful, because, detect if you use ( or not ) a vending machine in 500 mileseconds before i press F. I can stop the anim and give de the money and send a message, type "out of service". i think it useful, don't use detect position ( sometimes leave some sprunk or other's ) well,
good work i use
Reply
#8

i will use it
Reply
#9

simple but nice and usefull
keepitup!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)