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; }
- pawn Code:CreateVendingMachine(objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
- pawn Code:GetVendingMachineRot(machineid, &Float:rx, &Float:ry, &Float:rz);
- pawn Code:SetVendingMachineRot(machineid, Float:rx, Float:ry, Float:rz);
- pawn Code:GetVendingMachinePos(machineid, &Float:x, &Float:y, &Float:z);
- pawn Code:SetVendingMachinePos(machineid, Float:x, Float:y, Float:z);
- pawn Code:DestroyVendingMachine(machineid);
- pawn Code:GetVendingMachineType(machineid);
- pawn Code:SetVendingMachineColor(machineid, color);
- pawn Code:GetVendingMachineColor(machineid);
- pawn Code:IsValidVendingMachine(machineid);
- pawn Code:GetVendingMachineObjectID(machineid);
- 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.