SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 01/01/2015, 04:36 PM   #1
Larceny
Huge Clucker
 
Larceny's Avatar
 
Join Date: Apr 2006
Posts: 276
Reputation: 221
Default vending - Server-side vending machines


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

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;
}
Functions
  • pawn Code:
    CreateVendingMachine(objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);

    Creates a vending machine. returns the machine ID.
  • pawn Code:
    GetVendingMachineRot(machineid, &Float:rx, &Float:ry, &Float:rz);

    Gets the vending machine rotation, passed by reference.
  • pawn Code:
    SetVendingMachineRot(machineid, Float:rx, Float:ry, Float:rz);

    Sets the vending machine rotation.
  • pawn Code:
    GetVendingMachinePos(machineid, &Float:x, &Float:y, &Float:z);

    Gets the vending machine position.
  • pawn Code:
    SetVendingMachinePos(machineid, Float:x, Float:y, Float:z);

    Sets the vending machine position.
  • pawn Code:
    DestroyVendingMachine(machineid);

    Destroy a vending machine.
  • pawn Code:
    GetVendingMachineType(machineid);

    Gets the vending machine type.
  • pawn Code:
    SetVendingMachineColor(machineid, color);

    Sets the a vending machine color. (ARGB)
  • pawn Code:
    GetVendingMachineColor(machineid);

    Gets the vending machine color. (ARGB)
  • pawn Code:
    IsValidVendingMachine(machineid);

    Checks if a vending machine exist.
  • pawn Code:
    GetVendingMachineObjectID(machineid);

    Gets the ID of the objectid.
  • pawn Code:
    GetVendingMachineObjectType(machineid);

    returns OBJECT_TYPE_DYNAMIC if the machine is a dynamic object(streamer).
    returns OBJECT_TYPE_NORMAL if not.

    Just for reference.

Vending types

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>
Download

Github.

Last edited by Larceny; 07/08/2017 at 09:40 PM.
Larceny is online now   Reply With Quote
Old 02/01/2015, 05:33 AM   #2
SydthTV
Little Clucker
 
Join Date: Nov 2014
Posts: 13
Reputation: 3
Default Re: vending - Server-side vending machines

I'm surprised that no one has replied yet. This type of include could evolve into many other dynamic systems, and it would be great to see some more from you in the future. I'm going to replace the old vending machines with these so that they will support my anti-cheat.
__________________

Last edited by SydthTV; 02/01/2015 at 06:31 AM.
SydthTV is offline   Reply With Quote
Old 02/01/2015, 05:34 AM   #3
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,703
Reputation: 1176
Default Re: vending - Server-side vending machines

This is nice, it could replace the client sided vending machines and support linking with anti-cheats.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 02/01/2015, 12:57 PM   #4
ranslsad
Big Clucker
 
ranslsad's Avatar
 
Join Date: Jan 2010
Location: Malaga
Posts: 63
Reputation: 8
Default Respuesta: vending - Server-side vending machines

Realy good job, thanks alot.

Here you can see actual machines pos: http://gta.wikia.com/Vending_Machines

Greetings

Ranslsad
ranslsad is offline   Reply With Quote
Old 02/01/2015, 02:12 PM   #5
RayC
Big Clucker
 
RayC's Avatar
 
Join Date: Feb 2011
Posts: 142
Reputation: 20
Default Re: vending - Server-side vending machines

Thank you very much, this is pretty cool Great work.
__________________
RayC is offline   Reply With Quote
Old 02/01/2015, 02:37 PM   #6
Diabloa
Huge Clucker
 
Diabloa's Avatar
 
Join Date: Dec 2011
Location: Castillo
Posts: 393
Reputation: 100
Default Re: vending - Server-side vending machines

This is really amazing. SA-MP needed something like this.
Diabloa is offline   Reply With Quote
Old 04/01/2015, 07:08 PM   #7
Larceny
Huge Clucker
 
Larceny's Avatar
 
Join Date: Apr 2006
Posts: 276
Reputation: 221
Default Re: vending - Server-side vending machines

Thanks.

I got the coordinates of the single-player machines. Now the include replaces the single-player machines automatically, so no need to remove them manually.
Larceny is online now   Reply With Quote
Old 04/01/2015, 07:11 PM   #8
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,141
Reputation: 445
Default Re: vending - Server-side vending machines

Awesome! I was thinking of making something like this; but never actually did anything more than think about it. Very well done from the looks of it.
Abagail is offline   Reply With Quote
Old 05/01/2015, 06:01 AM   #9
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,042
Reputation: 827
Default Respuesta: vending - Server-side vending machines

Thanks a lot, this is nice

Btw, why you dont use y_iterate and dynamics areas (streamer) to optimize this?
Swedky is offline   Reply With Quote
Old 05/01/2015, 12:08 PM   #10
Larceny
Huge Clucker
 
Larceny's Avatar
 
Join Date: Apr 2006
Posts: 276
Reputation: 221
Default Re: vending - Server-side vending machines

Thanks.

I didn't want the user needed to download other includes to be able to use the include.
But i'm updating it to check if streamer is included, probably i'll do the same to y_iterate.
Larceny is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Remove Vending Machines AstonDA-G Filterscripts 22 11/10/2019 06:59 PM
Please help me how to fix this vending machin Lloyde Scripting Help 4 02/04/2014 12:14 AM
[FilterScript] [FS] Sprunkin || Vending Machines! Tr1viUm Filterscripts 20 29/12/2010 12:04 AM
Disabling Vending Machines MisterTickle Help Archive 2 25/07/2009 09:30 AM


All times are GMT. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.