i tried making revive in shop plugin but it not work, help me
PHP Code:
/*
* Description *
Allows players to buy respawn to return to play again, it is possible to set the price.
Converted my plugin for Sourcemod:
https://forums.alliedmods.net/showthread.php?p=1960942
* CVARs *
amxx_buyrespawn_enabled = 1/0 - plugin is enabled/disabled (def. 1)
amxx_buyrespawn_cost = 0-16000 - Set the price for the respawn (def. 500)
amxx_buyrespawn_per_round = 0-99 - Set the max respawns per round (def. 2)
amxx_buyrespawn_message = 1/0 plugin message is enabled/disabled (def. 1)
amxx_buyrespawn_version - current plugin version
* Commands *
!respawn
/respawn
* Changelog *
Version 1.0.0
Initial Release
Version 1.0.1
Updated with wickedd tips
Little clean code
Version 1.0.2
Now the plugin checks if the player is Spectator, to prevent bugs.
*/
/*
Libraries
*/
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <customshop>
#include <fakemeta>
/*
Plugin info
*/
#define PLUGIN "Buy Respawn"
#define VERSION "1.0.2"
#define AUTHOR "Rodrigo286"
/*
Variables
*/
#define PLUGIN_VERSION
additem ITEM_RESPAWN
#define RESPAWN_ID "respawn"
#define RESPAWN_NAME "Respawn"
#define RESPAWN_PRICE 15000
#define RESPAWN_LIMIT 1
new gCost;
new gUses;
new gEnabled;
new gMessages;
new respawns[33];
public plugin_precache()
ITEM_RESPAWN = cshopRegisterItem(RESPAWN_ID, RESPAWN_NAME, RESPAWN_PRICE, RESPAWN_LIMIT)
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
/*
Cvars
*/
register_cvar("amxx_buy_respawn_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
gEnabled = register_cvar("amxx_buy_respawn_enabled", "1") // Plugin is enbaled?
//gCost = register_cvar("amxx_buy_respawn_cost", "0") // How much respawn cost?
//gUses = register_cvar("amxx_buy_respawn_per_round", "0") // How many respawns allowed per round?
//gMessages = register_cvar("amxx_buy_respawn_messages", "0") // Info messages enabled?
/*
Commands
*/
//register_clcmd("say !respawn", "respawnCMD"); // Command to buy respawn
//register_clcmd("say /respawn", "respawnCMD"); // Command to buy respawn
/*
Events
*/
register_event("HLTV", "LogEvent_RoundStart", "a", "1=0", "2=0");
}
public LogEvent_RoundStart()
{
arrayset(respawns, 0, sizeof(respawns));
}
public respawnCMD(client)
{
/*
Get player money
*/
new money = cs_get_user_money(client);
/*
Get respawn cost
*/
new cost = get_pcvar_num(gCost);
/*
Get respawn max uses allowed
*/
new uses = get_pcvar_num(gUses);
/*
Calculate payment value of respawn
*/
new payment = money - cost;
/*
Get message enabled cvar value
*/
new messages = get_pcvar_num(gMessages);
/*
Get if player is spector or unassigned
*/
if(get_user_team(client) == 3 || get_user_team(client) == 0)
{
if(messages != 0)
client_print(client, print_chat, "[AmxModX] Choose a team before purchasing a respawn.");
return PLUGIN_HANDLED;
}
if(get_pcvar_num(gEnabled) != 1)
{
if(messages != 0)
client_print(client, print_chat, "[AmxModX] Buy respawn is disabled at this time.");
return PLUGIN_HANDLED;
}
if(is_user_alive(client))
{
if(messages != 0)
client_print(client, print_chat, "[AmxModX] You need to be dead to buy a new life.");
return PLUGIN_HANDLED;
}
if(uses == respawns[client])
{
if(messages != 0)
client_print(client, print_chat, "[AmxModX] Have you ever reached the maximum usage released by round.");
return PLUGIN_HANDLED;
}
if(money < cost)
{
if(messages != 0)
client_print(client, print_chat, "[AmxModX] You dont have money to respawn, it costs $%d", cost);
return PLUGIN_HANDLED;
}
/*
Set user money to pay for respawn
*/
cs_set_user_money(client, payment);
/*
Spawn player using hamsandwich
*/
ExecuteHamB(Ham_CS_RoundRespawn, client);
/*
Add +1 to respawn uses
*/
respawns[client] += 1;
/*
Print message to player
*/
if(messages != 0)
client_print(client, print_chat, "[AmxModX] You bouth a new life for $%d of money", cost);
return PLUGIN_CONTINUE;
}
public client_connect(client)
{
/*
Reset respawn uses on player connect
*/
respawns[client] = 0;
}