samp.directory
← Scripts et bibliothèques

wuzi/vending

Server-side vending machines for SA-MP

Bibliothèque★ 17mis à jour oct. 2019MITPawn
Ouvrir sur GitHub
L’essayer dans le compilateur Pawn →

Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.

Utilisé par 1 paquet

README.md

Vending

A SA-MP library to create server-sided vending machines giving you full control machines. You can create new machines anywhere.

Example

new gVending;

main()
{
	gVending = CreateVendingMachine(MACHINE_SPRUNK, 1755.348144, -2113.468750, 12.692808, 0.000000, 0.000000, 180.000000);
}

// Called when the player use the machine.
public OnPlayerUseVendingMachine(playerid, machineid)
{
	// Cancel the action if the player has no money.
	if(GetPlayerMoney(playerid) < 1)
	{
		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;
}

// Called when the player drink from the can.
public OnPlayerDrinkSprunk(playerid)
{
	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;
}

Creating

You can use the vending creator to create and export vending machines.

pawnsa-mpvending

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

wuzi/vending : Bibliothèque SA-MP | samp.directory