AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help my plugin bank (https://forums.alliedmods.net/showthread.php?t=208920)

DJ Fox 02-18-2013 21:09

Help my plugin bank
 
eai staff all good?

I was redoing a bank for zombie plague and renpente arises errors:
[IMG]http://img341.**************/img341/9825/imagemhou.jpg[/IMG]
what do can help me please, I am still very inexperienced

Plugin:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define is_valid_player(%1) (1 <= %1 <= 32)
#pragma dynamic 32768

new Handle:g_SqlTuple
new g_AP[33]
new g_DonateID[33]

public plugin_init()
{
register_clcmd("takeAmount", "cmdTakeAmount")
register_clcmd("saveAmount", "cmdSaveAmount")
register_clcmd("donate", "cmdDonate")
register_clcmd("say /bank", "menuBank")
register_clcmd("say_team /bank", "menuBank")

}

public menuBank(id)
{

new title[100]

formatex(title, 99, "[Bank \yAmmopacks :\r %i\w]", g_AP[id])


new bankMenu = menu_create(title, "menuBankHandler")

menu_additem(bankMenu, "\wTake Amount", "1")
menu_additem(bankMenu, "\wTake All^n", "2")

menu_additem(bankMenu, "\wSave Amount", "3")
menu_additem(bankMenu, "\wSave All^n", "4")

menu_additem(bankMenu, "\wDonate Amout^n^n", "5")


menu_display(id, bankMenu, 0)
}

}

public menuBankHandler(id, menu, item)
{
new data[6], iName[64], access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)

new key = str_to_num(data)

switch(key)
{
case 1:
{
client_cmd(id, "messagemode takeAmount")
}
case 2:
{
cmdTakeAll(id)
}
case 3:
{
client_cmd(id, "messagemode saveAmount")
}
case 4:
{
cmdSaveAll(id)
}
case 5:
{
menuDonate(id)
}
}
}

public cmdTakeAmount(id)
{
new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

new iApsSum = iAps + zp_get_user_ammo_packs(id)

if(iAps <= g_AP[id] && iApsSum <= 999)
{
zp_set_user_ammo_packs(id, iApsSum)
g_AP[id] -= iAps

client_print(id, print_chat, "[Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])

return PLUGIN_CONTINUE
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks or you wanted to take too much Ammopacks.")
}

return PLUGIN_CONTINUE
}

public cmdTakeAll(id)
{
new iApsSum = zp_get_user_ammo_packs(id) + g_AP[id]

if(iApsSum <= 999)
{
zp_set_user_ammo_packs(id, iApsSum)

client_print(id, print_chat, "[Bank] You took all %i Ammopacks from your Bank.", g_AP[id])

g_AP[id] = 0
}
else if(iApsSum > 999)
{
new giveAps = 999 - zp_get_user_ammo_packs(id)

if(giveAps <= g_AP[id])
{
zp_set_user_ammo_packs(id, giveAps + zp_get_user_ammo_packs(id))
g_AP[id] -= giveAps

client_print(id, print_chat, "[Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank.", giveAps, g_AP[id])
}
}
}

public cmdSaveAmount(id)
{
new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

new haveAps = zp_get_user_ammo_packs(id)

if(iAps <= haveAps)
{
zp_set_user_ammo_packs(id, haveAps - iAps)
g_AP[id] += iAps

client_print(id, print_chat, "[Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks")
}

return PLUGIN_CONTINUE
}

public cmdSaveAll(id)
{
new haveAps = zp_get_user_ammo_packs(id)

zp_set_user_ammo_packs(id, 0)
g_AP[id] += haveAps

client_print(id, print_chat, "[Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopackt in your Bank.", haveAps, g_AP[id])
}

public menuDonate(id)
{
new DonateMenu = menu_create("\rChoose A player to Donate:", "menuDonateHandler")

new players[32], pnum, tempid

new szName[32], szTempid[10]

get_players(players, pnum)

for( new i; i<pnum; i++ )
{
tempid = players[i]

if(id != tempid)
{
get_user_name(tempid, szName, 31)
num_to_str(tempid, szTempid, 9)

menu_additem(DonateMenu, szName, szTempid, 0)
}
}

menu_display(id, DonateMenu, 0)
}

public menuDonateHandler(id, menu, item)
{
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

new tempid = str_to_num(data);

g_DonateID[id] = tempid

client_cmd(id, "messagemode donate")

menu_destroy(menu);
return PLUGIN_HANDLED;
}

public cmdDonate(id)
{

new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

if(iAps <= g_AP[id])
{
// Take iAps away
g_AP[id] -= iAps

new NameDonate[45]
get_user_name(g_DonateID[id], NameDonate, 44)
new Name[45]
get_user_name(g_DonateID[id], Name, 44)

client_print(id, print_chat, "[Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank.", iAps, NameDonate, g_AP[id])

// give iAps to Donateid
g_AP[g_DonateID[id]] += iAps
client_print(g_DonateID[id], print_chat, "[Bank] %s donated %i Ammopacks to you. Now you have %i Ammopacks in your Bank.", Name, iAps, g_AP[g_DonateID[id]])
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks")
}

return PLUGIN_CONTINUE
}

public plugin_end()
{
SQL_FreeHandle(g_SqlTuple)
}

EDUTz 02-18-2013 21:31

Re: Help my plugin bank
 
Code:

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define is_valid_player(%1) (1 <= %1 <= 32)
#pragma dynamic 32768

new Handle:g_SqlTuple
new g_AP[33]
new g_DonateID[33]

public plugin_init()
{
register_clcmd("takeAmount", "cmdTakeAmount")
register_clcmd("saveAmount", "cmdSaveAmount")
register_clcmd("donate", "cmdDonate")
register_clcmd("say /bank", "menuBank")
register_clcmd("say_team /bank", "menuBank")

}

public menuBank(id)
{       

new title[100]

formatex(title, 99, "[Bank \yAmmopacks :\r %i\w]", g_AP[id])


new bankMenu = menu_create(title, "menuBankHandler")

menu_additem(bankMenu, "\wTake Amount", "1")
menu_additem(bankMenu, "\wTake All^n", "2")

menu_additem(bankMenu, "\wSave Amount", "3")
menu_additem(bankMenu, "\wSave All^n", "4")

menu_additem(bankMenu, "\wDonate Amout^n^n", "5")


menu_display(id, bankMenu, 0)
}


public menuBankHandler(id, menu, item)
{       
new data[6], iName[64], access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)

new key = str_to_num(data)

switch(key)
{
case 1:
{
client_cmd(id, "messagemode takeAmount")
}
case 2:
{
cmdTakeAll(id)
}
case 3:
{
client_cmd(id, "messagemode saveAmount")
}
case 4:
{
cmdSaveAll(id)
}
case 5:
{
menuDonate(id)
}
}
}

public cmdTakeAmount(id)
{
new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

new iApsSum = iAps + zp_get_user_ammo_packs(id)

if(iAps <= g_AP[id] && iApsSum <= 999)
{
zp_set_user_ammo_packs(id, iApsSum)
g_AP[id] -= iAps

client_print(id, print_chat, "[Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])

return PLUGIN_CONTINUE
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks or you wanted to take too much Ammopacks.")
}

return PLUGIN_CONTINUE
}

public cmdTakeAll(id)
{
new iApsSum = zp_get_user_ammo_packs(id) + g_AP[id]

if(iApsSum <= 999)
{
zp_set_user_ammo_packs(id, iApsSum)

client_print(id, print_chat, "[Bank] You took all %i Ammopacks from your Bank.", g_AP[id])

g_AP[id] = 0
}
else if(iApsSum > 999)
{
new giveAps = 999 - zp_get_user_ammo_packs(id)

if(giveAps <= g_AP[id])
{
zp_set_user_ammo_packs(id, giveAps + zp_get_user_ammo_packs(id))
g_AP[id] -= giveAps

client_print(id, print_chat, "[Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank.", giveAps, g_AP[id])
}
}
}

public cmdSaveAmount(id)
{
new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

new haveAps = zp_get_user_ammo_packs(id)

if(iAps <= haveAps)
{
zp_set_user_ammo_packs(id, haveAps - iAps)
g_AP[id] += iAps

client_print(id, print_chat, "[Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank.", iAps, g_AP[id])
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks")
}

return PLUGIN_CONTINUE
}

public cmdSaveAll(id)
{
new haveAps = zp_get_user_ammo_packs(id)

zp_set_user_ammo_packs(id, 0)
g_AP[id] += haveAps

client_print(id, print_chat, "[Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopackt in your Bank.", haveAps, g_AP[id])
}

public menuDonate(id)
{
new DonateMenu = menu_create("\rChoose A player to Donate:", "menuDonateHandler")

new players[32], pnum, tempid

new szName[32], szTempid[10]

get_players(players, pnum)

for( new i; i<pnum; i++ )
{
tempid = players[i]

if(id != tempid)
{
get_user_name(tempid, szName, 31)
num_to_str(tempid, szTempid, 9)

menu_additem(DonateMenu, szName, szTempid, 0)
}
}

menu_display(id, DonateMenu, 0)
}

public menuDonateHandler(id, menu, item)
{       
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

new tempid = str_to_num(data);

g_DonateID[id] = tempid

client_cmd(id, "messagemode donate")

menu_destroy(menu);
return PLUGIN_HANDLED;
}

public cmdDonate(id)
{

new szAps[11]
read_args(szAps, 10)
remove_quotes(szAps)

if(equal(szAps, "") || equal(szAps, " "))
return PLUGIN_HANDLED

new iAps = str_to_num(szAps)

if(iAps < 1) return PLUGIN_HANDLED

if(iAps <= g_AP[id])
{
// Take iAps away
g_AP[id] -= iAps

new NameDonate[45]
get_user_name(g_DonateID[id], NameDonate, 44)
new Name[45]
get_user_name(g_DonateID[id], Name, 44)

client_print(id, print_chat, "[Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank.", iAps, NameDonate, g_AP[id])

// give iAps to Donateid
g_AP[g_DonateID[id]] += iAps
client_print(g_DonateID[id], print_chat, "[Bank] %s donated %i Ammopacks to you. Now you have %i Ammopacks in your Bank.", Name, iAps, g_AP[g_DonateID[id]])
}
else
{
client_print(id, print_chat, "[Bank] You dont have enough Ammopacks")
}

return PLUGIN_CONTINUE
}

public plugin_end()
{
SQL_FreeHandle(g_SqlTuple)
}


DJ Fox 02-19-2013 12:18

thank you so !

UP!

Sorry not even have spoken and so I'm giving this UP!

I'm already with the plugin registry and how it registers by name, I was wondering how I would do to save the bank by name only for the two to become a set and they can only use the bank who is registered!

I really do!

simanovich 02-20-2013 03:20

Re: Help my plugin bank
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define is_valid_player(%1) (1 <= %1 <= 32)
#pragma dynamic 32768

new Handle:g_SqlTuple
new g_AP[33]
new 
g_DonateID[33]

public 
plugin_init(){
    
register_clcmd("takeAmount""cmdTakeAmount");
    
register_clcmd("saveAmount""cmdSaveAmount");
    
register_clcmd("donate""cmdDonate");
    
register_clcmd("say /bank""menuBank");
    
register_clcmd("say_team /bank""menuBank");
}

public 
menuBank(id){
    new 
title[100];
    
    
formatex(title99"[Bank \yAmmopacks :\r %i\w]"g_AP[id]);
    
    new 
bankMenu menu_create(title"menuBankHandler");
    
    
menu_additem(bankMenu"\wTake Amount""1");
    
menu_additem(bankMenu"\wTake All^n""2");
    
    
menu_additem(bankMenu"\wSave Amount""3");
    
menu_additem(bankMenu"\wSave All^n""4");
    
    
menu_additem(bankMenu"\wDonate Amout^n^n""5");
    
    
menu_display(idbankMenu0);
}

public 
menuBankHandler(idmenuitem)
{
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1client_cmd(id"messagemode takeAmount")
        case 
2cmdTakeAll(id)
        case 
3client_cmd(id"messagemode saveAmount")
        case 
4cmdSaveAll(id)
        case 
5menuDonate(id)
    }
}

public 
cmdTakeAmount(id)
{
new 
szAps[11]
read_args(szAps10)
remove_quotes(szAps)

if(
equal(szAps"") || equal(szAps" "))
return 
PLUGIN_HANDLED

new iAps str_to_num(szAps)

if(
iAps 1) return PLUGIN_HANDLED

new iApsSum iAps zp_get_user_ammo_packs(id)

if(
iAps <= g_AP[id] && iApsSum <= 999)
{
zp_set_user_ammo_packs(idiApsSum)
g_AP[id] -= iAps

client_print
(idprint_chat"[Bank] You took %i Ammopacks from Your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])

return 
PLUGIN_CONTINUE
}
else
{
client_print(idprint_chat"[Bank] You dont have enough Ammopacks or you wanted to take too much Ammopacks.")
}

return 
PLUGIN_CONTINUE
}

public 
cmdTakeAll(id)
{
new 
iApsSum zp_get_user_ammo_packs(id) + g_AP[id]

if(
iApsSum <= 999)
{
zp_set_user_ammo_packs(idiApsSum)

client_print(idprint_chat"[Bank] You took all %i Ammopacks from your Bank."g_AP[id])

g_AP[id] = 0
}
else if(
iApsSum 999)
{
new 
giveAps 999 zp_get_user_ammo_packs(id)

if(
giveAps <= g_AP[id])
{
zp_set_user_ammo_packs(idgiveAps zp_get_user_ammo_packs(id))
g_AP[id] -= giveAps

client_print
(idprint_chat"[Bank] You took %i Ammopacks from your Bank. Now you have %i Ammopacks in your Bank."giveApsg_AP[id])
}
}
}

public 
cmdSaveAmount(id)
{
new 
szAps[11]
read_args(szAps10)
remove_quotes(szAps)

if(
equal(szAps"") || equal(szAps" "))
return 
PLUGIN_HANDLED

new iAps str_to_num(szAps)

if(
iAps 1) return PLUGIN_HANDLED

new haveAps zp_get_user_ammo_packs(id)

if(
iAps <= haveAps)
{
zp_set_user_ammo_packs(idhaveAps iAps)
g_AP[id] += iAps

client_print
(idprint_chat"[Bank] You saved %i Ammopacks in your Bank. Now you have %i Ammopacks in your Bank."iApsg_AP[id])
}
else
{
client_print(idprint_chat"[Bank] You dont have enough Ammopacks")
}

return 
PLUGIN_CONTINUE
}

public 
cmdSaveAll(id)
{
new 
haveAps zp_get_user_ammo_packs(id)

zp_set_user_ammo_packs(id0)
g_AP[id] += haveAps

client_print
(idprint_chat"[Bank] You saved %i Ammopacks to your Bank. Now you have %i Ammopackt in your Bank."haveApsg_AP[id])
}

public 
menuDonate(id)
{
new 
DonateMenu menu_create("\rChoose A player to Donate:""menuDonateHandler")

new 
players[32], pnumtempid

new szName[32], szTempid[10]

get_players(playerspnum)

for( new 
ii<pnumi++ )
{
tempid players[i]

if(
id != tempid)
{
get_user_name(tempidszName31)
num_to_str(tempidszTempid9)

menu_additem(DonateMenuszNameszTempid0)
}
}

menu_display(idDonateMenu0)
}

public 
menuDonateHandler(idmenuitem)
{
new 
data[6], iName[64];
new 
accesscallback;
menu_item_getinfo(menuitemaccessdata,5iName63callback);

new 
tempid str_to_num(data);

g_DonateID[id] = tempid

client_cmd
(id"messagemode donate")

menu_destroy(menu);
return 
PLUGIN_HANDLED;
}

public 
cmdDonate(id)
{

new 
szAps[11]
read_args(szAps10)
remove_quotes(szAps)

if(
equal(szAps"") || equal(szAps" "))
return 
PLUGIN_HANDLED

new iAps str_to_num(szAps)

if(
iAps 1) return PLUGIN_HANDLED

if(iAps <= g_AP[id])
{
// Take iAps away
g_AP[id] -= iAps

new NameDonate[45]
get_user_name(g_DonateID[id], NameDonate44)
new 
Name[45]
get_user_name(g_DonateID[id], Name44)

client_print(idprint_chat"[Bank] You donated %i Ammopacks to %s. Now you have %i ammopacks in your Bank."iApsNameDonateg_AP[id])

// give iAps to Donateid
g_AP[g_DonateID[id]] += iAps
client_print
(g_DonateID[id], print_chat"[Bank] %s donated %i Ammopacks to you. Now you have %i Ammopacks in your Bank."NameiApsg_AP[g_DonateID[id]])
}
else
{
client_print(idprint_chat"[Bank] You dont have enough Ammopacks")
}

return 
PLUGIN_CONTINUE
}

public 
plugin_end()
{
SQL_FreeHandle(g_SqlTuple)



DJ Fox 02-20-2013 15:28

Re: Help my plugin bank
 
he still is not saving the Ammo Packs friend by name every time I change the map disappear AP = (

EDUTz 02-20-2013 15:38

Re: Help my plugin bank
 
this plugin is not saving anything ! search for another one ..

DJ Fox 02-20-2013 15:50

Re: Help my plugin bank
 
but how has this, only I do not know, and learn what I want =)


All times are GMT -4. The time now is 21:40.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.