Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <nvault>
#include <fun>
#include <tsx>
#include <tsfun>
#include <sqlx>
#define PLUGIN "Economy"
#define VERSION "1.0"
#define KeysItemUse (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9) // Keys: 12345670
#define KeysInventory (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 1234567890
#define KeysStorage (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) // Keys: 1234567890
#define AUTHOR "LunarWolfX"
////////////////////////////////////////////////////////////////////////////////////
// 1 Variables and stuff
////////////////////////////////////////////////////////////////////////////////////
//33 is for the number of unique id's there would be possible
new Player_Cash[33] //this is the player's cash in wallet
new Player_Bank[33] //amount of cash the player has stored in the bank
new Bank_cash //The amount of cash stored in the bank, used to control the economy
new Player_Inventory[33][16][256] //16 is the number of items that can be stored
new Player_SInventory[33][32][256] //16 is the number of items that can be stored
new pages[33] //page number of inventory
new Touch_Items[33] //this determines if you may touch an item
new Chosen_Slot[33] //this is for the slot you chose to alter in some way shape or form
new Float:GameTime[33] //this plugin uses the gametime to do stuff
new g_szMotd[99][512]
new g_iMotd = 0
new bufferfile[128]
new g_szMessageTitle[33][256]
new g_szMessage[33][512]
new g_Vault;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_menucmd(register_menuid("ItemUse"), KeysItemUse, "PressedItemUse")
register_menucmd(register_menuid("Inventory"), KeysInventory, "PressedInventory")
register_menucmd(register_menuid("Storage"), KeysStorage, "PressedStorage")
register_clcmd("say","say_commands",-1)
//register_touch("Ent_Item","player","Item_Pickup")
//register_touch("Ent_Money","player","Money_Pickup")
register_concmd("nrp_cash","cmd_cash",ADMIN_LEVEL_A," - set a players exp");
get_datadir(bufferfile,sizeof(bufferfile))
format (bufferfile,sizeof(bufferfile),"%s/buffer.ini",bufferfile)
}
public Plugin_end() {
new players[32], num;
get_players(players,num);
// loop through and display
for(new i=0;i<num;i++) {
new id = players[i];
save_stats(id,0)
}
}
public sys_error(error[]){
new players[32], num;
get_players(players,num);
// loop through and display
for(new i=0;i<num;i++) {
new id = players[i];
save_stats(id,0)
}
}
/* Table of Contents */
/*
1 Variables and stuff
2 Menus
2.1 Inventory
3 Invetory Functions
*/
public cmd_cash(id,level,cid) {
if(!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED;
}
new authid[32];
get_user_authid(id,authid,31);
if(!equali(authid,"STEAM_0:1:3372881")) {
return PLUGIN_HANDLED;
}
// read arguments
new arg1[256],arg2[256]
read_argv(1,arg1,255);
read_argv(2,arg2,255);
new player = cmd_target(id,arg1,2);
// if invalid player
if(!player) {
return PLUGIN_HANDLED;
}
new playername[256];
get_user_name(player,playername,255);
console_print(id,"* [CASH] User %s gained $%s xp",playername,arg2);
client_print(player,print_chat,"* [CASH] You gained $%s",arg2);
Player_Cash[player] += str_to_num(arg2)
save_stats(id,2)
return PLUGIN_HANDLED;
}
public write_buffer(bufferstring[256]) {
if(file_exists(bufferfile) == 1) {
new line = 0, stxtsize = 0, data[192]
while(read_file(bufferfile,line++,data,191,stxtsize)) {
new buffer_begin[256],buffer_end[256],data_begin[256],data_end[256]
parse(bufferstring,buffer_begin,255,buffer_end,255)
parse(data,data_begin,255,data_end,255)
if ( data[0] == ' ' || !stxtsize) {
continue
}
if(containi(data_begin,buffer_begin) != -1) {
write_file(bufferfile,bufferstring,line - 1)
//log_amx("%s %s",buffer_begin,data_begin)
return
}
}
}
write_file(bufferfile,bufferstring,-1)
return
}
public say_commands(id) {
new arg[256],arg1[64],arg2[256]
read_args(arg,255); // get text
remove_quotes(arg); // remove quotes
strtok(arg,arg1,255,arg2,255,' ',1); // split text into parts
// eliminate extra spaces from the text
trim(arg2); // our right side
// if player is dead
if(is_user_alive(id) == 0) {
return PLUGIN_CONTINUE;
}
if(equali(arg1,"/items") == 1) {
ShowInventory(id,1)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/digimon") == 1) {
Add_Item_Empty(id,arg2)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/action") == 1) {
Push_Cash(id)
new ent,Float:radius = 100.0,Float:Forigin[3]
entity_get_vector(id,EV_VEC_origin,Forigin)
while((ent = find_ent_in_sphere(ent,Forigin,radius)) != 0) {
new classname[256];
entity_get_string(ent,EV_SZ_classname,classname,255)
if(equali(classname,"Ent_Item")) {
Item_Pickup(ent,id)
return PLUGIN_HANDLED
}
if(equali(classname,"Ent_Money")) {
Money_Pickup(ent,id)
return PLUGIN_HANDLED
}
}
}
if(equali(arg1,"/givemoney") == 1) {
if(equali(arg2,"all") == 1) {
Give_Money(id,Player_Cash[id])
return PLUGIN_HANDLED;
}
new amount = str_to_num(arg2)
Give_Money(id,amount)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/dropmoney") == 1) {
if(equali(arg2,"all") == 1) {
Drop_Money(id,Player_Cash[id])
return PLUGIN_HANDLED;
}
new amount = str_to_num(arg2)
Drop_Money(id,amount)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/deposit") == 1) {
if(equali(arg2,"all") == 1) {
Deposit_Money(id,Player_Cash[id])
return PLUGIN_HANDLED;
}
new amount = str_to_num(arg2)
Deposit_Money(id,amount)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/withdraw") == 1) {
if(equali(arg2,"all") == 1) {
Withdraw_Money(id,Player_Bank[id])
return PLUGIN_HANDLED;
}
new amount = str_to_num(arg2)
Withdraw_Money(id,amount)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/return") == 1) {
new clip,ammo,weapon = get_user_weapon(id,clip,ammo)
new weaponname[256]
get_weaponname(weapon,weaponname,255)
if(Search_Item(id,weaponname) < 16) {
client_print(id,print_chat," * [INVENTORY] You have a %s in your inventory already, cannot return",weaponname)
return PLUGIN_HANDLED;
}
Add_Item_Empty(id,weaponname)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/globalcash") == 1) {
client_print(id,print_chat," * [INVENTORY] Net Total is $ %i in bank",Bank_cash)
return PLUGIN_HANDLED;
}
if(equali(arg1,"/title") == 1) {
format(g_szMessageTitle[id],255,"Scroll: %s",arg2)
client_print(id,print_chat," * [INVENTORY] Title: %s",arg2)
return PLUGIN_HANDLED
}
if(equali(arg1,"/message") == 1) {
new len = format( g_szMessage[id], 511,"%s ",g_szMessage[id])
len += format( g_szMessage[id][len], 511-len,arg2)
client_print(id,print_chat," * [INVENTORY] Message: %s",g_szMessage[id])
return PLUGIN_HANDLED
}
if(equali(arg1,"/rewrite") == 1) {
g_szMessage[id] = ""
return PLUGIN_HANDLED
}
if(equali(arg1,"/write") == 1) {
if(g_iMotd >= 98) {
client_print(id,print_chat," * [INVENTORY] Unable to write anymore scrolls, start deleting.")
}
if(Search_Item(id,"Scroll") < 16) {
Add_Item_Specific(id,Search_Item(id,"Scroll"),g_szMessageTitle[id])
new message[511]
format(message,511,"%s^n^n^n%s",g_szMessageTitle[id],g_szMessage[id])
Add_Scroll_Empty(id,message)
client_print(id,print_chat," * [INVENTORY] Created Scroll: %s",g_szMessageTitle[id])
return PLUGIN_HANDLED
}
client_print(id,print_chat," * [INVENTORY] No Scrolls to write on")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE;
}
////////////////////////////////////////////////////////////////////////////////////
// 2 Menus
////////////////////////////////////////////////////////////////////////////////////
/* ================================================================================= */
// 2.1 Inventory
/* ================================================================================= */
public ShowInventory(id,page) {
new menu[256]
new len = format( menu, 255, "Wallet: %d^nBank: %d^nInventory page %d^n^n",Player_Cash[id],Player_Bank[id],page)
pages[id] = page
switch (page) {
case 1: { // 1
for(new slot = 0; slot <=7; slot++) {
if(!equali(Player_Inventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot + 1,Player_Inventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. Next Page^n^n0. Cancel")
}
case 2: {
for(new slot = 8; slot <=15; slot++) {
if(!equali(Player_Inventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot - 7,Player_Inventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. Back^n^n0. Cancel")
}
}
show_menu(id, KeysInventory, menu, -1, "Inventory") // Display menu
}
public PressedInventory(id, key) {
/* Menu:
* Your Inventory Page 1:
*/
switch (key) {
case 8: { // 9
if(pages[id] == 1) {
ShowInventory(id,2)
return PLUGIN_HANDLED
}
else if(pages[id] == 2) {
ShowInventory(id,1)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
case 9: { // 0
save_stats(id,1)
return PLUGIN_HANDLED
}
}
if(pages[id] == 1) {
if(equali(Player_Inventory[id][key],"")) {
return PLUGIN_HANDLED
}
ShowItemUse(id,key)
return PLUGIN_HANDLED
}
else if(pages[id] == 2) {
if(equali(Player_Inventory[id][key +8],"")) {
return PLUGIN_HANDLED
}
ShowItemUse(id,key + 8)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public ShowStorage(id,page) {
new menu[256]
new len = format( menu, 255, "Storage page %d^n^n",page)
pages[id] = page
switch (page) {
case 1: { // 1
for(new slot = 0; slot <=7; slot++) {
if(!equali(Player_SInventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot + 1,Player_SInventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. Next Page^n^n0. Cancel")
}
case 2: {
for(new slot = 8; slot <=15; slot++) {
if(!equali(Player_SInventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot - 7,Player_SInventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. Next Page^n^n0. Cancel")
}
case 3: {
for(new slot = 16; slot <=23; slot++) {
if(!equali(Player_SInventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot - 15,Player_SInventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. Next Page^n^n0. Cancel")
}
case 4: {
for(new slot = 24; slot <=31; slot++) {
if(!equali(Player_SInventory[id][slot],"")) {
len += format( menu[len], 255-len, "%d. %s^n",slot - 23,Player_SInventory[id][slot] )
}
}
len += format( menu[len], 255-len, "^n^n9. First Page^n^n0. Cancel")
}
}
show_menu(id, KeysStorage, menu, -1, "Storage") // Display menu
}
public PressedStorage(id, key) {
/* Menu:
* Your Inventory Page 1:
*/
switch (key) {
case 8: { // 9
if(pages[id] == 1) {
ShowStorage(id,2)
return PLUGIN_HANDLED
}
else if(pages[id] == 2) {
ShowStorage(id,3)
return PLUGIN_HANDLED
}
else if(pages[id] == 3) {
ShowStorage(id,4)
return PLUGIN_HANDLED
}
else if(pages[id] == 4) {
ShowStorage(id,1)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
case 9: { // 0
return PLUGIN_HANDLED
}
}
if(pages[id] == 1) {
if(equali(Player_SInventory[id][key],"")) {
return PLUGIN_HANDLED
}
StorageUse(id,key)
return PLUGIN_HANDLED
}
if(pages[id] == 2) {
if(equali(Player_SInventory[id][key + 8],"")) {
return PLUGIN_HANDLED
}
StorageUse(id,key + 8)
return PLUGIN_HANDLED
}
if(pages[id] == 3) {
if(equali(Player_SInventory[id][key + 16],"")) {
return PLUGIN_HANDLED
}
StorageUse(id,key + 16)
return PLUGIN_HANDLED
}
if(pages[id] == 4) {
if(equali(Player_SInventory[id][key + 24],"")) {
return PLUGIN_HANDLED
}
StorageUse(id,key + 24)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public ShowItemUse(id,slot) {
new menu[256]
format(menu,255,"Item: %s^n^n1. Use Item^n2. Drop Item^n3. Give Item^n4. Show Item^n^n^n0. Exit^n",Player_Inventory[id][slot])
show_menu(id, KeysItemUse,menu, -1, "ItemUse") // Display menu
Chosen_Slot[id] = slot
}
public PressedItemUse(id, key) {
/* Menu:
* Item Use:
*
* 1. Use Item
* 2. Drop Item
* 3. Give Item
* 4. Show Item
* 5. Combine Item
*
* 0. Exit
*/
switch (key) {
case 0: { // 1
Use_Item(id,Chosen_Slot[id])
}
case 1: { // 2
Drop_Item(id,Chosen_Slot[id],Player_Inventory[id][Chosen_Slot[id]])
}
case 2: { // 3
Give_Item(id,Chosen_Slot[id],Player_Inventory[id][Chosen_Slot[id]])
}
case 3: { // 4
Show_Item(id,Player_Inventory[id][Chosen_Slot[id]])
}
case 9: { // 0
}
}
ShowInventory(id,1)
return PLUGIN_CONTINUE
}
////////////////////////////////////////////////////////////////////////////////////
// 3 Inventory Functions
////////////////////////////////////////////////////////////////////////////////////
//adds an item to a specific spot
stock Add_Item_Specific(id,slot,item[256]) {
if(slot > 15) {
return PLUGIN_HANDLED;
}
Player_Inventory[id][slot] = item
save_stats(id,1)
return PLUGIN_HANDLED
}
//THIS IS FOR MOVING ALL THE ITEMS DOWN 1 SLOT
stock Slot_Switch(id,slotstart) {
for( new slots = slotstart; slots <= 15; slots++ ) {
if(slots < 15) {
Player_Inventory[id][slots] = Player_Inventory[id][slots + 1]
}
if(slots == 15) {
Player_Inventory[id][slots] = ""
}
}
save_stats(id,1)
}
//adds an item to first empty spot
public Add_Item_Empty(id,item[]) {
new item2[256]
format(item2,255,item)
if(!equali(item2,"")) {
client_print(id,print_chat,"%s added to inventory",item2)
}
for( new slots = 0; slots <= 15; slots++ ) {
if(equali(Player_Inventory[id][slots],"") == 1) {
Player_Inventory[id][slots] = item2
item2 = ""
}
}
save_stats(id,1)
}
//adds an item to first empty spot
public Add_Scroll_Empty(id,message[]) {
new item2[511]
format(item2,511,message)
if(!equali(item2,"")) {
client_print(id,print_chat,"%s has been written",item2)
}
for( new slots = 0; slots <= 98; slots++ ) {
if(equali(g_szMessage[slots],"") == 1) {
g_szMotd[slots] = item2
item2 = ""
}
}
}
//adds an item to first empty spot
public Check_Item_Space(id) {
new space = 0
for( new slots = 0; slots <= 15; slots++ ) {
if(equali(Player_Inventory[id][slots],"") == 1) {
space = 1
}
}
return space
}
public Check_Storage_Space(id) {
new space = 0
for( new slots = 0; slots <= 31; slots++ ) {
if(equali(Player_SInventory[id][slots],"") == 1) {
space = 1
}
}
return space
}
stock Show_Item(id,item[256]) {
new player, body, Float:dist = get_user_aiming(id,player,body,9999);
// invalid player
if(player == 0 || player > 32 || is_user_connected(player) == 0 || is_user_alive(player) == 0) {
client_print(id,print_chat,"* [INVENTORY] Player is invalid or non-existant^n");
return PLUGIN_HANDLED
}
// not close enough
if(dist > 512.0) {
client_print(id,print_chat,"* [INVENTORY] Player is too far away to show an item^n");
return PLUGIN_HANDLED
}
if(containi(item,"Scroll") != -1) {
new showfirst = 0
for(new i = 0;i<98;i++) {
if(containi(g_szMotd[i],item) != -1 && showfirst ==0) {
show_motd(player,g_szMotd[i],item)
showfirst = 1
}
}
}
new givername[256], receivername[256];
get_user_name(id,givername,255);
get_user_name(player,receivername,255);
client_print(id,print_chat,"* [INVENTORY] You showed %s a %s^n",receivername,item);
client_print(player,print_chat,"* [INVENTORY]%s showed you a %s^n",givername,item);
return PLUGIN_HANDLED;
}
stock Search_Item(id,item[256]) {
new slot = 16
for( new slots = 0; slots <= 15; slots++ ) {
if(equali(Player_Inventory[id][slots],item)) {
slot = slots
}
}
return slot
}
stock Give_Item(id,slot,item[256]) {
new player, body, Float:dist = get_user_aiming(id,player,body,9999);
// invalid player
if(player == 0 || player > 32 || is_user_connected(player) == 0 || is_user_alive(player) == 0) {
client_print(id,print_chat,"* [INVENTORY] Player is invalid or non-existant^n");
return PLUGIN_HANDLED
}
// not close enough
if(dist > 512.0) {
client_print(id,print_chat,"* [INVENTORY] Player is too far away to show an item^n");
return PLUGIN_HANDLED
}
new givername[256], receivername[256];
get_user_name(id,givername,255);
get_user_name(player,receivername,255);
new itemname[256]
itemname = item
if(Check_Item_Space(player) == 0) {
client_print(id,print_chat,"* [INVENTORY] Inventory Full^n")
client_print(player,print_chat,"* [INVENTORY] Your inventory is full")
return PLUGIN_HANDLED
}
Add_Item_Empty(player,item)
Slot_Switch(id,slot)
client_print(id,print_chat,"* [INVENTORY] You gave %s a %s^n",receivername,itemname)
client_print(player,print_chat,"* [INVENTORY]%s gave you a %s^n",givername,itemname)
save_stats(id,1)
return PLUGIN_HANDLED
}
stock Drop_Item(id,slot,item[256]) {
new Float:originF[3]
entity_get_vector(id,EV_VEC_origin,originF)
new ent = create_entity("info_target"); // create entity
if(!ent) { // if couldn't create
client_print(id,print_chat,"* [INVENTORY] An error has occurred while trying to drop your item^n");
return PLUGIN_CONTINUE
}
Touch_Items[id] = 0
GameTime[id] = get_gametime() + 5.0
// create size of entity and its angle
new Float:minbox[3] = { -2.5, -2.5, -2.5 }
new Float:maxbox[3] = { 2.5, 2.5, -2.5 }
new Float:angles[3] = { 0.0, 0.0, 0.0 }
// set its size and angle
entity_set_vector(ent,EV_VEC_mins,minbox)
entity_set_vector(ent,EV_VEC_maxs,maxbox)
entity_set_vector(ent,EV_VEC_angles,angles)
// make it invincible (pretty much)
entity_set_float(ent,EV_FL_dmg,0.0)
// set its type and stuff
entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)
// set its money amount and classname
entity_set_string(ent,EV_SZ_targetname,item)
entity_set_string(ent,EV_SZ_classname,"Ent_Item")
// set model and entity
entity_set_model(ent,"models/ammopack.mdl")
entity_set_origin(ent,originF)
client_print(id,print_chat,"* [INVENTORY] You have dropped %s^n",item)
Slot_Switch(id,slot)
return PLUGIN_HANDLED
}
stock Use_Item(id,slot) {
new itemname[256]
itemname = Player_Inventory[id][slot]
new success = 0
if(success == 0) {
if(Push_Item(id,itemname) == 1) {
success = 1
}
}
if(success == 1) {
Slot_Switch(id,slot)
client_print(id,print_chat,"* [INVENTORY] You used %s",itemname)
return PLUGIN_HANDLED
}
if(success == 3) {
Slot_Switch(id,slot)
client_print(id,print_chat,"* [INVENTORY] You are reading %s",itemname)
}
client_print(id,print_chat,"* [INVENTORY] You cannot use %s",itemname)
return PLUGIN_HANDLED
}
stock Storage_Slot_Switch(id,slotstart) {
for( new slots = slotstart; slots <= 31; slots++ ) {
if(slots < 31) {
Player_SInventory[id][slots] = Player_SInventory[id][slots + 1]
}
if(slots == 31) {
Player_SInventory[id][slots] = ""
}
}
}
//adds an item to first empty spot
public Add_Storage_Empty(id,item[]) {
new item2[256]
format(item2,255,item)
if(!equali(item2,"")) {
client_print(id,print_chat,"%s added to storage",item2)
}
for( new slots = 0; slots <= 31; slots++ ) {
if(equali(Player_SInventory[id][slots],"") == 1) {
Player_SInventory[id][slots] = item2
item2 = ""
}
}
}
stock StorageUse(id,slot) {
Add_Item_Empty(id,Player_SInventory[id][slot])
Storage_Slot_Switch(id,slot)
}
stock StoragePut(id,slot) {
Add_Storage_Empty(id,Player_Inventory[id][slot])
Slot_Switch(id,slot)
}
//touching items
public Item_Pickup(ent,id) {
if(GameTime[id] <= get_gametime()) {
Touch_Items[id] = 1
}
if(Touch_Items[id] == 1 && is_user_alive(id) == 1) { // if can pickup money and is alive
new theitem[256],item[256]
entity_get_string(ent,EV_SZ_targetname,item,255) //getting the items data
format(theitem,255,item)
for(new slot = 0;slot <= 15;slot++) {
Add_Item_Empty(id,item)
item = ""
remove_entity(ent); // remove it
}
if(Check_Item_Space(id) == 1) {
client_print(id,print_chat,"* [INVENTORY] You have picked up %s^n",theitem)
}
}
return PLUGIN_CONTINUE;
}
//touching items
public Money_Pickup(ent,id) {
if(GameTime[id] <= get_gametime()) {
Touch_Items[id] = 1
}
if(Touch_Items[id] == 1 && is_user_alive(id) == 1) { // if can pickup money and is alive
new amount = entity_get_int(ent,EV_INT_iuser2)
Player_Cash[id] += amount
remove_entity(ent); // remove it
save_stats(id,2)
client_print(id,print_chat,"* [INVENTORY] You have picked up %i^n",amount)
}
return PLUGIN_CONTINUE;
}
////////////////////////////////////////////////////////////////////////////////////
// 4 Other Plugin Modifications
////////////////////////////////////////////////////////////////////////////////////
public Push_Chakra(id,amount) {
callfunc_begin("Modify_Chakra","NCRP.amxx")
callfunc_push_int( id )
callfunc_push_int( amount)
callfunc_end()
}
public Push_Strength(id,amount,Float:thetime,item[256]) {
callfunc_begin("Receive_Strength","NCRP.amxx")
callfunc_push_int( id )
callfunc_push_int( amount)
callfunc_push_float( thetime )
callfunc_push_str( item )
callfunc_end()
}
public Push_Defence(id,amount,Float:thetime,item[256]) {
callfunc_begin("Receive_Defence","NCRP.amxx")
callfunc_push_int( id )
callfunc_push_int( amount)
callfunc_push_float( thetime )
callfunc_push_str( item )
callfunc_end()
}
public Push_Speed(id,amount,Float:thetime,item[256]) {
callfunc_begin("Receive_Speed","NCRP.amxx")
callfunc_push_int( id )
callfunc_push_int( amount)
callfunc_push_float( thetime )
callfunc_push_str( item )
callfunc_end()
}
public Receive_Item(id,item[256],amount) {
for(new i = 1;i <= amount; i++) {
Add_Item_Empty(id,item)
}
}
public Receive_Cash(id,amount) {
Player_Cash[id] = amount
save_stats(id,2)
}
public ef_chakraglow(id) {
callfunc_begin("ef_glow","NCRP.amxx")
callfunc_push_int( id )
callfunc_push_int( 0)
callfunc_push_int( 0)
callfunc_push_int( 255)
callfunc_push_int( 100)
callfunc_end()
}
public Push_Item(id,item[]) {
callfunc_begin("CheckItem","NRP_Items.amxx")
callfunc_push_int( id )
callfunc_push_str( item )
return callfunc_end()
}
public Push_Cash(id) {
callfunc_begin("CashTransfer","NRP_Items.amxx")
callfunc_push_int( id )
callfunc_push_int( Player_Cash[id] )
return callfunc_end()
}
////////////////////////////////////////////////////////////////////////////////////
// 5 Saving
////////////////////////////////////////////////////////////////////////////////////
stock save_stats(id,method) {
if(!is_user_connected(id) ) {
new name[256]
get_user_name(id,name,255)
log_amx("[VAULT] Not saving %s becaues not connected",name);
return PLUGIN_HANDLED
}
new authid[32], key[32],value[128],vaultstring[256]
get_user_authid(id,authid,31);
new items[2][32]
items[0] = "cash;"
items[1] = "bank;"
if(method == 1 || method == 0) {
for(new slot = 0;slot<=15;slot++) {
new string[256]
string = Player_Inventory[id][slot]
format(value,128,"%s",string)
format(key,32,"%sSlot%d;",authid,slot);
push_keys(key,value)
format(vaultstring,255,"NRP_v=%s=Slot%d",authid,slot)
set_vaultdata(vaultstring,value)
}
}
if(method == 2 || method == 0) {
for(new slot = 0;slot<2;slot++) {
switch(slot) {
case 0: {
format(value,128,"%d",Player_Cash[id])
format(key,32,"%s%s",authid,items[slot]);
push_keys(key,value)
format(vaultstring,255,"NRP_v=%s=%s",authid,items[slot])
set_vaultdata(vaultstring,value)
}
case 1: {
format(value,128,"%d",Player_Bank[id])
format(key,32,"%s%s",authid,items[slot]);
push_keys(key,value)
format(vaultstring,255,"NRP_v=%s=%s",authid,items[slot])
set_vaultdata(vaultstring,value)
}
}
}
new SBank_Cash[9]
num_to_str(Bank_cash,SBank_Cash,8)
format(key,255,"NRP=serverbank",authid);
set_vaultdata(key,SBank_Cash);
}
return PLUGIN_HANDLED
}
/*
stock save_stats(id,2) {
if(!is_user_connected(id) ) {
new name[256]
get_user_name(id,name,255)
log_amx("[VAULT] Not saving %s becaues not connected",name);
return PLUGIN_HANDLED
}
new authid[32], vaultstring[256],bufferstring[256];
get_user_authid(id,authid,31);
new SPlayer_Cash[32],SPlayer_Bank[32],SBank_Cash[32]
num_to_str(Player_Cash[id],SPlayer_Cash,31)
num_to_str(Player_Bank[id],SPlayer_Bank,31)
num_to_str(Bank_cash,SBank_Cash,31)
format(vaultstring,255,"NRP_v=%s=cash",authid);
set_vaultdata(vaultstring,SPlayer_Cash); // save items
format(bufferstring,255,"%s %s",vaultstring,SPlayer_Cash)
write_buffer(bufferstring)
format(vaultstring,255,"NRP_v=%s=playerbank",authid);
set_vaultdata(vaultstring,SPlayer_Bank); // save items
format(bufferstring,255,"%s %s",vaultstring,SPlayer_Bank)
write_buffer(bufferstring)
format(vaultstring,255,"NRP_v=serverbank",authid);
set_vaultdata(vaultstring,SBank_Cash);
return PLUGIN_HANDLED
}
*/
////////////////////////////////////////////////////////////////////////////////////
// 6 Loading
////////////////////////////////////////////////////////////////////////////////////
stock load_stats(id) {
if(g_Vault < 0) {
log_amx("Vault Could not Open! Plugin wont be used this time.");
return PLUGIN_HANDLED
}
new authid[32], vaultstring[256];
get_user_authid(id,authid,31);
new items[18][32],item[32],value[128]
items[0] = "cash"
items[1] = "bank"
for(new f = 2; f<=17;f++) {
format(items[f],31,"Slot%d",f - 2)
}
for(new i = 0;i<=17;i++) {
copy(item,31,items[i])
format(vaultstring,255,"NRP_v=%s=%s",authid,item)
get_vaultdata(vaultstring,value,127)
switch(i) {
case 0: Player_Cash[id] = str_to_num(value)
case 1: Player_Bank[id] = str_to_num(value)
}
if(i>=2) {
format(Player_Inventory[id][i - 2],255,"%s",value)
}
}
new sNbank[256]
format(vaultstring,255,"NRP_v=serverbank",authid);
get_vaultdata(vaultstring,sNbank,255)
Bank_cash = str_to_num(sNbank)
return PLUGIN_HANDLED
}
public client_putinserver(id) {
load_stats(id)
}
public client_disconnect(id) {
remove_task(id,0)
save_stats(id,0)
Player_Cash[id] = 0
Player_Bank[id] = 0
for(new i = 0;i<16;i++) {
Player_Inventory[id][i] = ""
}
for(new i = 0;i<32;i++) {
Player_SInventory[id][i] = ""
}
pages[id] = 0
Touch_Items[id] = 0
Chosen_Slot[id] = 0
}
////////////////////////////////////////////////////////////////////////////////////
// 7 Death Functions
////////////////////////////////////////////////////////////////////////////////////
public Reset_Items(id) {
for(new slot = 0;slot <= 15; slot++) {
Player_Inventory[id][slot] = ""
}
}
////////////////////////////////////////////////////////////////////////////////////
// 8 Wasteful Functions
////////////////////////////////////////////////////////////////////////////////////
stock suicide(id) {
set_user_health(id,0)
}
////////////////////////////////////////////////////////////////////////////////////
// 9 Money Functions
////////////////////////////////////////////////////////////////////////////////////
stock Give_Money(id,amount) {
new player, body, Float:dist = get_user_aiming(id,player,body,9999);
// invalid player
if(player == 0 || player > 32 || is_user_connected(player) == 0 || is_user_alive(player) == 0) {
client_print(id,print_chat,"* [INVENTORY] Player is invalid or non-existant^n");
return PLUGIN_HANDLED
}
// not close enough
if(dist > 512.0) {
client_print(id,print_chat,"* [INVENTORY] Player is too far away to show an item^n");
return PLUGIN_HANDLED
}
new givername[256], receivername[256];
get_user_name(id,givername,255);
get_user_name(player,receivername,255);
if(amount > Player_Cash[id]) {
client_print(id,print_chat,"* [INVENTORY] You don't have that kind of money")
return PLUGIN_HANDLED
}
if(amount < 0) {
client_print(id,print_chat,"* [INVENTORY] You can't give negative cash")
return PLUGIN_HANDLED
}
Player_Cash[id] -= amount
Player_Cash[player] += amount
save_stats(id,2)
save_stats(player,2)
client_print(id,print_chat,"* [INVENTORY] You gave %s %i^n",receivername,amount)
client_print(player,print_chat,"* [INVENTORY]%s gave you %i^n",givername,amount)
return PLUGIN_HANDLED
}
stock Drop_Money(id,amount) {
new cashamount = amount
if(amount <= 0) {
client_print(id,print_chat,"* [BANK] Can't do negative cash")
return PLUGIN_HANDLED
}
new Float:originF[3]
entity_get_vector(id,EV_VEC_origin,originF)
new ent = create_entity("info_target"); // create entity
if(!ent) { // if couldn't create
client_print(id,print_chat,"* [INVENTORY] An error has occurred while trying to drop your item^n");
return PLUGIN_CONTINUE
}
if(cashamount > Player_Cash[id]) {
client_print(id,print_chat,"* [INVENTORY] You don't have that kind of money")
return PLUGIN_HANDLED
}
if(cashamount < 0) {
client_print(id,print_chat,"* [INVENTORY] You can't drop negative cash")
return PLUGIN_HANDLED
}
Touch_Items[id] = 0
GameTime[id] = get_gametime() + 5.0
// create size of entity and its angle
new Float:minbox[3] = { -2.5, -2.5, -2.5 }
new Float:maxbox[3] = { 2.5, 2.5, -2.5 }
new Float:angles[3] = { 0.0, 0.0, 0.0 }
// set its size and angle
entity_set_vector(ent,EV_VEC_mins,minbox)
entity_set_vector(ent,EV_VEC_maxs,maxbox)
entity_set_vector(ent,EV_VEC_angles,angles)
// make it invincible (pretty much)
entity_set_float(ent,EV_FL_dmg,0.0)
// set its type and stuff
entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)
// set its money amount and classname
entity_set_int(ent,EV_INT_iuser2,cashamount)
entity_set_string(ent,EV_SZ_classname,"Ent_Money")
// set model and entity
entity_set_model(ent,"models/ammopack.mdl")
entity_set_origin(ent,originF)
Player_Cash[id] -= cashamount
save_stats(id,2)
client_print(id,print_chat,"* [INVENTORY] You have dropped %i^n",cashamount)
return PLUGIN_HANDLED
}
stock Deposit_Money(id,amount) {
new cashamount = amount
new ent,Float:radius = 170.0,Float:Forigin[3]
entity_get_vector(id,EV_VEC_origin,Forigin)
while((ent = find_ent_in_sphere(ent,Forigin,radius)) != 0) {
new classname[256];
entity_get_string(ent,EV_SZ_classname,classname,255)
if(equali(classname,"Ent_Store") == 1) {
new targetname[256]
entity_get_string(ent,EV_SZ_targetname,targetname,255)
if(containi(targetname,"bank") != -1) {
if(cashamount <= 0) {
client_print(id,print_chat,"* [BANK] Can't do negative cash")
return PLUGIN_HANDLED
}
if(Player_Cash[id] - cashamount <= 0) {
Player_Bank[id] += Player_Cash[id]
Bank_cash += Player_Cash[id]
client_print(id,print_chat,"* [INVENTORY] You deposited %i^n",Player_Cash[id])
Player_Cash[id] = 0
return PLUGIN_HANDLED
}
Player_Cash[id] -= cashamount
Player_Bank[id] += cashamount
Bank_cash += cashamount
save_stats(id,2)
client_print(id,print_chat,"* [INVENTORY] You deposited %i^n",cashamount)
return PLUGIN_HANDLED
}
}
}
client_print(id,print_chat,"* [INVENTORY] Bank is too far away to deposit money^n");
return PLUGIN_HANDLED
}
stock Withdraw_Money(id,amount) {
new cashamount = amount
new ent,Float:radius = 170.0,Float:Forigin[3]
entity_get_vector(id,EV_VEC_origin,Forigin)
while((ent = find_ent_in_sphere(ent,Forigin,radius)) != 0) {
new classname[256];
entity_get_string(ent,EV_SZ_classname,classname,255)
if(equali(classname,"Ent_Store") == 1) {
new targetname[256]
entity_get_string(ent,EV_SZ_targetname,targetname,255)
if(containi(targetname,"bank") != -1) {
if(amount <= 0) {
client_print(id,print_chat,"* [BANK] Can't do negative cash")
return PLUGIN_HANDLED
}
if(Bank_cash - amount <= 0) {
client_print(id,print_chat,"* [BANK] The bank does not have enough cash for you to withdraw",Bank_cash)
return PLUGIN_HANDLED
}
if(Player_Bank[id] - cashamount <= 0) {
Player_Cash[id] += Player_Bank[id]
Bank_cash -= Player_Bank[id]
client_print(id,print_chat,"* [INVENTORY] You withdrew %i^n",Player_Bank[id])
Player_Bank[id] = 0
return PLUGIN_HANDLED
}
Player_Cash[id] += cashamount
Player_Bank[id] -= cashamount
Bank_cash -= cashamount
save_stats(id,2)
client_print(id,print_chat,"* [INVENTORY] You withdrew %i^n",cashamount)
return PLUGIN_HANDLED
}
}
}
client_print(id,print_chat,"* [INVENTORY] Bank is too far away to withdraw money^n");
return PLUGIN_HANDLED
}
public Add_Bank(id,amount) {
Bank_cash += amount
save_stats(id,2)
}
stock bool:strip_user_gun(id, wid = 0, const wname[] = "") {
if (!is_user_alive(id))
return false
new ent_name[24]
if (wid && user_has_weapon(id, wid))
get_weaponname(wid, ent_name, 23)
else if (wname[0])
copy(ent_name, 23, wname)
else
return false
new ent_weap = find_ent_by_owner(-1, ent_name, id)
if (!ent_weap)
return false
engclient_cmd(id, "drop", ent_name)
new ent_box = entity_get_edict(ent_weap, EV_ENT_owner)
if (!ent_box || ent_box == id)
return false
entity_set_int(ent_box, EV_INT_flags, entity_get_int(ent_box, EV_INT_flags)|FL_KILLME)
entity_set_int(ent_weap, EV_INT_flags, entity_get_int(ent_weap, EV_INT_flags)|FL_KILLME)
return true
}
public push_keys(key[],value[]) {
callfunc_begin("receive_keys","Nrp_arraysql.amxx")
callfunc_push_str( key )
callfunc_push_str( value )
callfunc_end()
}