AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Moneymod for sven co-op (https://forums.alliedmods.net/showthread.php?t=27160)

styno 04-15-2006 23:32

Moneymod for sven co-op
 
yo, i wanted to have a money mod for Sven co-op so i started scripting but somthing isn't right....

if you say amx_money you should see:You have YOUR_MONEY_HERE $
Code:
#include <amxmodx> new moneyhave[]=500 public plugin_init()     {     register_plugin("Money Mod","1.00","StYn0!")     register_menucmd(register_menuid("Moneymod Menu"), 1023, "mh_Adminmoneymenu")     register_clcmd("amx_moneymenu", "md_showmoneyMenu", -1, " ")     register_concmd("amx_money", "showmoney", -1, "Show your money") } public showmoney(id)     {     client_print(0,print_chat,"You have %s $",moneyhave)     return PLUGIN_CONTINUE } //end of showmoney /* Menu Admin money menu */ public mh_Adminmoneymenu(id, key) {     new name[32], authid[16]     get_user_name(id, name, 31)     get_user_authid(id, authid, 16)     switch(key) {         //give to 1         case 0: {             client_cmd(id, "localAddmoney(id,100)")         }         //give to all         case 1: {             client_cmd(id, "amx_pbmenu")//not yet         }         //take from 1         case 2: {             client_cmd(id, "amx_pbmenu")//not yet         }             //take from all         case 3: {             client_cmd(id, "amx_pbmenu")//not yet         }     }     return PLUGIN_HANDLED } //end of menu public md_showmoneyMenu(id, level, cid) {     new menu[256]     format(menu, 255, "Moneymod Menu^n^n1. Give money to 1 player^n2. Give money to all players^n3. Take money from 1 player^n4. Take money from all players^n5. Exit")     show_menu(id, ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)), menu)     return PLUGIN_HANDLED } //---------------------------------------------------------------------------------------------- //This function is the ONLY way this plugin should add/subtract money to a player //There are checks to prevent overflowing //To take money away just send the function a negative (-) number public localAddmoney(id, money) {     if (money > 0 && moneyhave[id] + money < moneyhave[id]) {         moneyhave[id] = 2147483647     }     else if (money < 0 && (moneyhave[id] + money < -1000000 || moneyhave[id] + money > moneyhave[id])) {         moneyhave[id] = -1000000     }     else {         moneyhave[id] += money     } } //end

cheers

Goshik 04-16-2006 05:57

well, it should work ;)

Code:
#include <amxmodx> new moneyhave[]=500 public plugin_init()     {     register_plugin("Money Mod","1.00","StYn0!")     register_menucmd(register_menuid("Moneymod Menu"), 1023, "mh_Adminmoneymenu")     register_clcmd("amx_moneymenu", "md_showmoneyMenu", -1, " ")     register_concmd("amx_money", "showmoney", -1, "Show your money") } public showmoney(id)     {     client_print(0,print_chat,"You have %s $",moneyhave)     return PLUGIN_CONTINUE } //end of showmoney /* Menu Admin money menu */ public mh_Adminmoneymenu(id, key) {     new name[32], authid[16]     get_user_name(id, name, 31)     get_user_authid(id, authid, 16)     switch(key) {         //give to 1         case 0: {             client_cmd(id, "localAddmoney(id,100)")         }         //give to all         case 1: {             client_cmd(id, "amx_pbmenu")//not yet         }         //take from 1         case 2: {             client_cmd(id, "amx_pbmenu")//not yet         }             //take from all         case 3: {             client_cmd(id, "amx_pbmenu")//not yet         }     }     return PLUGIN_HANDLED } //end of menu public md_showmoneyMenu(id, level, cid) {     new menu[256]     format(menu, 255, "Moneymod Menu^n^n1. Give money to 1 player^n2. Give money to all players^n3. Take money from 1 player^n4. Take money from all players^n5. Exit")     show_menu(id, ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)), menu)     return PLUGIN_HANDLED } //---------------------------------------------------------------------------------------------- //This function is the ONLY way this plugin should add/subtract money to a player //There are checks to prevent overflowing //To take money away just send the function a negative (-) number public localAddmoney(id, money) {     if (money > 0 && moneyhave[id] + money < moneyhave[id]) {         moneyhave[id] = 2147483647     }     else if (money < 0 && (moneyhave[id] + money < -1000000 || moneyhave[id] + money > moneyhave[id])) {         moneyhave[id] = -1000000     }     else {         moneyhave[id] += money     } }

styno 04-16-2006 17:02

When i want to compile it i geth an error:

/home/users/amxmodx/tmp3/phpvJ1dYC.sma(47) : error 037: invalid string (possibly non-terminated string)
/home/users/amxmodx/tmp3/phpvJ1dYC.sma(47 -- 49) : error 001: expected token: ",", but found "-identifier-"
/home/users/amxmodx/tmp3/phpvJ1dYC.sma(49) : warning 217: loose indentation
/home/users/amxmodx/tmp3/phpvJ1dYC.sma(49) : error 017: undefined symbol "player"
/home/users/amxmodx/tmp3/phpvJ1dYC.sma(49) : fatal error 107: too many error messages on one line

Goshik 04-16-2006 17:09

2 Attachment(s)
mine compiles fine

styno 04-23-2006 10:22

When i type amx_money i just see:

you have $

With no numers, i do amx_moneymenu and choose 1(add money)

and i still see

you have $

P34nut 04-23-2006 10:49

change
Code:
client_print(0,print_chat,"You have %s $",moneyhave)
into
Code:
 client_print(0,print_chat,"You have %d $",moneyhave)

styno 04-26-2006 16:40

nope :cry:

Greenberet 04-26-2006 17:51

try this
Code:
#include <amxmodx> new moneyhave[33]={500,...} public plugin_init() {     register_plugin("Money Mod","1.00","StYn0!")     register_menucmd(register_menuid("Moneymod Menu"), 1023, "mh_Adminmoneymenu")     register_clcmd("amx_moneymenu", "md_showmoneyMenu", -1, " ")     register_concmd("amx_money", "showmoney", -1, "Show your money") } public showmoney(id) {     client_print(id,print_chat,"You have %d $",moneyhave[id])     return PLUGIN_CONTINUE } //end of showmoney /* Menu Admin money menu */ public mh_Adminmoneymenu(id, key) {     new name[32], authid[16]     get_user_name(id, name, 31)     get_user_authid(id, authid, 16)     switch(key)     {         //give to 1         case 0:         {             client_cmd(id, "localAddmoney(id,100)")         }         //give to all         case 1:         {             client_cmd(id, "amx_pbmenu")//not yet         }         //take from 1         case 2:         {             client_cmd(id, "amx_pbmenu")//not yet         }             //take from all         case 3:         {             client_cmd(id, "amx_pbmenu")//not yet         }     }     return PLUGIN_HANDLED } //end of menu public md_showmoneyMenu(id, level, cid) {     new menu[256]     formatex(menu, 255, "Moneymod Menu^n^n1. Give money to 1 player^n2. Give money to all players^n3. Take money from 1" )     format(menu, 255, "%s player^n4. Take money from all players^n5. Exit", menu )     show_menu(id, ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)), menu)     return PLUGIN_HANDLED } //---------------------------------------------------------------------------------------------- //This function is the ONLY way this plugin should add/subtract money to a player //There are checks to prevent overflowing //To take money away just send the function a negative (-) number public localAddmoney(id, money) {     if (money > 0 && moneyhave[id] + money < moneyhave[id])     {         moneyhave[id] = 2147483647     }     else if (money < 0 && (moneyhave[id] + money < -1000000 || moneyhave[id] + money > moneyhave[id]))     {         moneyhave[id] = -1000000     }     else     {         moneyhave[id] += money     } }

styno 04-27-2006 01:46

nope, i changed my script to this....

Code:
#include <amxmodx> new moneyhave[33]={500,...} public plugin_init()       {       register_plugin("Money Mod","1.00","StYn0!")       register_clcmd("amx_givemoney", "localmoney",ADMIN_LEVEL_A, "<authid, nick, @team or #userid> <money>")       register_concmd("amx_money", "showmoney", -1, "Show your money")   }   public showmoney(id)       {       client_print(0,print_chat,"You have %d $",moneyhave)       return PLUGIN_CONTINUE   }   //----------------------------------------------------------------------------------------------   //This function is the ONLY way this plugin should add/subtract money to a player   //There are checks to prevent overflowing   //To take money away just send the function a negative (-) number   public localAddmoney(id, money)   {     if (money > 0 && moneyhave[id] + money < moneyhave[id]) {           moneyhave[id] = 2147483647       }       else if (money < 0 && (moneyhave[id] + money < -1000000 || moneyhave[id] + money > moneyhave[id])) {           moneyhave[id] = -1000000       }       else {           moneyhave[id] += money       }   }

styno 04-27-2006 12:14

bump?(i added this code but now i cant even do amx_money anymore )


All times are GMT -4. The time now is 05:04.

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