AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Global Variable (https://forums.alliedmods.net/showthread.php?t=45350)

JPiolho 09-30-2006 10:07

Global Variable
 
I've searched but I've found nothing about my problem.

Im doing a RPG plugin that should work with all mods, but im based on sven co-op, and I'm doing multiple plugins that make only 1 like some rpg plugins, and I want to make save plugin to read money plugin to know the money variable. But I dint found out how to do it, any help plz? :) Here is code:

jprp_economy.amxx
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <jprp> new bool:plugin_loaded new money[33] public plugin_init() {     if(is_plugin_loaded("JPRP Core"))     {         plugin_loaded = true         mod_economy = true     }     else     {         plugin_loaded = false     }             if(!plugin_loaded)         return PLUGIN_CONTINUE         register_plugin("JPRP: Economy","1.0","JPiolho")             register_clcmd("jprp_economy_give","economy_give",-1,"<player> <amount> - Give the money to the player")         set_task(1.0,"economy_update_money")         return PLUGIN_CONTINUE } public economy_update_money() {     set_hudmessage(93, 233, 149, 0.01, 0.48, 0, 6.0, 1.0, 0.0, 0.0, 30)         for(new x = 1; x < 32; x++)     {         if(is_user_connected(x))         {             show_hudmessage(x, "Money: %d$",money[x])         }     }             set_task(1.0,"economy_update_money")         return PLUGIN_CONTINUE } public client_putinserver(id) {     if(!plugin_loaded)         return PLUGIN_CONTINUE             money[id] = 150         return PLUGIN_CONTINUE } public economy_give(id) {     if(!plugin_loaded)         return PLUGIN_CONTINUE             new name[33]     new temp_arg[33]         new p_name[2][33]         new player     new money_x         read_argv(1,name,32)         player = cmd_target(1,name,4)         if(player)     {         read_argv(2,temp_arg,32)                 money_x = str_to_num(temp_arg)                 if(money_x < 1)         {             client_print(id,print_chat,"[JPRP Economy] You can't give less than 1$")             return PLUGIN_CONTINUE         }                 if(money[id] - money_x < 0)         {             client_print(id,print_chat,"[JPRP Economy] Insufficient Funds")             return PLUGIN_CONTINUE         }                         money[id] = money[id] - money_x         money[player] = money[player] + money_x                 get_user_name(id,p_name[0],32)         get_user_name(player,p_name[1],32)                 client_print(id,print_chat,"[JPRP Economy] You gave %d$ to %s",money_x,p_name[1])         client_print(player,print_chat,"[JPRP Economy] You received %d$ from %s",money_x,p_name[0])     }         return PLUGIN_CONTINUE }

jprp_core.amxx
Code:
#include <amxmodx> #include <amxmisc> #include <jprp> public plugin_init() {     register_plugin("JPRP Core","1.0","JPiolho")         register_cvar("jprp_core_version", "1.0", 0) }

jprp_save.amxx
Code:
#include <amxmodx> #include <amxmisc> #include <file> #include <jprp> new bool:plugin_loaded new filepath[513] public plugin_init() {     if(is_plugin_loaded("JPRP Core"))     {         plugin_loaded = true         mod_save = true     }     else     {         plugin_loaded = false     }         if(!plugin_loaded)         return PLUGIN_CONTINUE         new configdir[513]         register_plugin("JPRP: Save","1.0","JPiolho")         register_concmd("jprp_save","client_disconnect")         get_configsdir(configdir,512)         format(filepath,512,"%s/jprp/save",configdir)         return PLUGIN_CONTINUE } public client_connect(id) {     set_task(1.0,"save_load",id) } public save_load(id) {     } public client_disconnect(id) {     new file[513]     new steamid[65]         new temp1[33]     new temp2[33]     new temp3[33]     new temp4[33]                 new full_steamid[65]         get_user_authid(id,steamid,65)         strtok(steamid, temp1, 32, temp2, 32, ':', 0)         strtok(temp2,temp3,32,temp4,32,':')     //STEAM_0:0:9880045         format(full_steamid,64,"%s-%s-%s",temp1,temp3,temp4)         client_print(id,print_chat,"SteamID: %s",full_steamid)         format(file,512,"%s/%s.txt",filepath,full_steamid)         client_print(id,print_chat,"Filepath: %s",file)         if(is_plugin_loaded("JPRP: Economy"))     {         new money[33]                 num_to_str(money[id], money, 32)                 write_file(file, money, 0)     } }

jprp.inc
Code:
#include <amxmodx> #include <amxmisc> new bool:mod_economy = false new bool:mod_save = false stock jprp_is_mod_running(const mod[]) {       if(equali(mod,"economy"))     {         return mod_economy     }     else if(equali(mod,"save"))     {         return mod_save     }           return 0 }

Silencer123 10-01-2006 09:28

Re: Global Variable
 
So you want a plugin to change a variable in another plugin?
If yes, ditto!

Hawk552 10-01-2006 10:29

Re: Global Variable
 
Use dynamic natives.


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

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