01.01.2015, 15:36
(
Last edited by Larceny; 07/08/2017 at 08:40 PM.
)
Introduction
An include to create server-side vending machines that gives you full control of the in-game vending machines.
It automatically replaces the single-player machines. (since 1.6)
Example
Functions
Currently, there is 3 types of vending machines.
Streamer plugin
If streamer plugin is included before vending.inc it will use CreateDynamicObject instead of CreateObject.
Creating a vending
You can use the vendingcreator filterscript to help you creating vendings.




Special action
By default, when a player uses the sprunk machine they get a sprunk can and can drink from it. You can disable it by adding NO_SPRUNK_ACTION before the include.
Download
Github.
An include to create server-side vending machines that gives you full control of the in-game vending machines.
It automatically replaces the single-player machines. (since 1.6)
Example
Code:
new gVending;
main()
{
gVending = CreateVendingMachine(MACHINE_SPRUNK, 1755.348144, -2113.468750, 12.692808, 0.000000, 0.000000, 180.000000);
}
public OnPlayerUseVendingMachine(playerid, machineid)
{ // Called when the player use the machine.
if(GetPlayerMoney(playerid) < 1)
{// If the player has no money.
SendClientMessage(playerid, COLOR_ERROR, "* You don't have enough money.");
return 0;
}
// Restore 10% of player's health and takes 1$.
new Float:health;
GetPlayerHealth(playerid, health);
// Avoid player having more than 100.0 health.
if((health + 10.0) > 100.0) health = 100.0;
else health += 10.0;
// Give player stats
SetPlayerHealth(playerid, health);
GivePlayerMoney(playerid, -1);
return 1;
}
public OnPlayerDrinkSprunk(playerid)
{// Called when the player drink from the can.
new Float:health;
GetPlayerHealth(playerid, health);
if((health + 10.0) > 100.0) health = 100.0;
else health += 10.0;
SetPlayerHealth(playerid, health);
SendClientMessage(playerid, COLOR_INFO, "* You drank the sprunk. (+10HP)");
return 1;
}
- Creates a vending machine. returns the machine ID.pawn Code:CreateVendingMachine(objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
- Gets the vending machine rotation, passed by reference.pawn Code:GetVendingMachineRot(machineid, &Float:rx, &Float:ry, &Float:rz);
- Sets the vending machine rotation.pawn Code:SetVendingMachineRot(machineid, Float:rx, Float:ry, Float:rz);
- Gets the vending machine position.pawn Code:GetVendingMachinePos(machineid, &Float:x, &Float:y, &Float:z);
- Sets the vending machine position.pawn Code:SetVendingMachinePos(machineid, Float:x, Float:y, Float:z);
- Destroy a vending machine.pawn Code:DestroyVendingMachine(machineid);
- Gets the vending machine type.pawn Code:GetVendingMachineType(machineid);
- Sets the a vending machine color. (ARGB)pawn Code:SetVendingMachineColor(machineid, color);
- Gets the vending machine color. (ARGB)pawn Code:GetVendingMachineColor(machineid);
- Checks if a vending machine exist.pawn Code:IsValidVendingMachine(machineid);
- Gets the ID of the objectid.pawn Code:GetVendingMachineObjectID(machineid);
- returns OBJECT_TYPE_DYNAMIC if the machine is a dynamic object(streamer).pawn Code:GetVendingMachineObjectType(machineid);
returns OBJECT_TYPE_NORMAL if not.
Just for reference.
Currently, there is 3 types of vending machines.
Streamer plugin
If streamer plugin is included before vending.inc it will use CreateDynamicObject instead of CreateObject.
Creating a vending
You can use the vendingcreator filterscript to help you creating vendings.




Special action
By default, when a player uses the sprunk machine they get a sprunk can and can drink from it. You can disable it by adding NO_SPRUNK_ACTION before the include.
Code:
#define NO_SPRUNK_ACTION #include <vending>
Github.



Great work.
