Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- +----------+
- |**********| * * * * *** * * * * * ** ** ***
- |*******&&&| * * ** * * * * * * ** ** * _
- |@@*****&&@| ***** * * * * * * ***** *** *
- |*@@@***&&@| * * * ** ** * * ***
- |**@@***&@@|
- |*******@@@| 4ir W4ys's Sprunk Machine.
- |**********|
- |***%%%%***| Version: 1.1
- |**********| Features: *1* Creating a Spunk Machine in 1 Line. *2* 3D Text Supporting.
- +----------+ *3* Good For RolePlay Servers. *4* Anims Suppoting. *5* Controlled By the Defines.
- */
- #include <a_samp>
- #define SprunkCMD "/drink" // Change it, To the Command you want, The player will need to Type near the Sprunk Machine.
- #define PlaceErrorMessage "Warning: You are not near Sprunk/Snack Machine" // Change It, To the Message you want the server show, If the PlayerIsn't near Sprunk Machine...
- #define ErColor 0xFFFFFFFF // Change it, To the Color You want the server will send With the Error Messages ( It's Currectly White )
- #define Cost 3 // Change it, To the Cost of a drink in the Sprunk Machine.
- #define GiveHP 20 // Change it, To the Health the playe Will get if He using Sprunk Machine
- #define CostErrorMessage "Warning: You don't Have Enough Money." // Chanhe it, To the Message That will show if the player Don't hav Enought Money
- #define SPRUNK_COUNT 10 // Chanhe it, To the Max Sprunk Machnies you create'd ;D
- new SM[SPRUNK_COUNT];
- public OnFilterScriptInit()
- {
- SM[0] = CreateSprunkMachine(149.2466,-1949.1434,3.7734,73.6045);
- SM[1] = CreateSprunkMachine(148.9184,-1953.8967,3.7734,145);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp(SprunkCMD, cmdtext, true) == 0)
- {
- if(!IsPlayerNearSprunkMachine(playerid)) return SendClientMessage(playerid, ErColor, PlaceErrorMessage);
- if(GetPlayerMoney(playerid) < Cost) return SendClientMessage(playerid, ErColor, CostErrorMessage);
- GivePlayerMoney(playerid, -Cost);
- new Float:H;
- GetPlayerHealth(playerid, H);
- SetPlayerHealth(playerid, H+GiveHP);
- ApplyAnimation(playerid, "VENDING", "VEND_Drink2_P", 0, 0, 0, 0, 0, 4);
- return 1;
- }
- return 0;
- }
- stock CreateSprunkMachine(Float:X,Float:Y,Float:Z,Float:Angle)
- {
- CreateObject(955, Float:X, Float:Y, Float:Z-0.75, 0.0, 0.0, Float:Angle+180, 0.0);
- new Text[128];
- format(Text, sizeof(Text), "{FFFF00}Snack/Sprunk Machine.\nType %s to Use.", SprunkCMD);
- Create3DTextLabel(Text, 0xFFFF0000, Float:X, Float:Y, Float:Z, 40, 0, 0);
- return 1;
- }
- stock IsPlayerNearSprunkMachine(playerid)
- {
- for(new i; i < SPRUNK_COUNT; i++) if(IsPlayerNearObject(playerid, SM[i], 2.0)) return i;
- return -1;
- }
- stock IsPlayerNearObject(playerid, objectid, Float:range)
- {
- new Float:X, Float:Y, Float:Z;
- GetObjectPos(objectid, X, Y, Z);
- if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z)) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement