Raised This Month: $ Target: $400
 0% 

Help with my plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-01-2006 , 16:00  
#9

That's a terrible way of doing it. You should load the files on startup, then store them all in a global variable. Here, I'll show you:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> new filestr[84]; public plugin_init() {     register_plugin("Clan Models","0.1","Dizzy")     register_event("ResetHUD", "modelreset", "b")     new configs_dir[64]     get_configsdir(configs_dir , 63);     format(filestr, 83 , "%s/clanmodels.cfg" , configs_dir);     set_task(0.1 , "load_authids");     return PLUGIN_HANDLED } public plugin_precache() {     precache_model("models/clanter/clanter.mdl")     precache_model("models/clanct/clanct.mdl")     return PLUGIN_CONTINUE } new bool:can_change[33]; public client_connect(id) can_change[id] = false; public client_disconnect(id) can_change[id] = false; public modelreset(id) {     if(can_change[id])     {         new CsTeams:team = cs_get_user_team(id);         switch(team)         {             case CS_TEAM_T: cs_set_user_model(id , "clanter");             case CS_TEAM_CT: cs_set_user_model(id , "clanct");         }     } } public load_authids(id) {     if(file_exists(filestr))     {         new output[128]         new fHandle = fopen(filestr, "rt")         if(!fHandle)             return PLUGIN_CONTINUE         for(new a = 0; !feof(fHandle); a++)         {             //Get line             fgets(fHandle, output, 511)             remove_quotes(output);                 //Check if line is invalid             if(output[0] == ';' || !output[0] || output[0] == ' ' || output[0] == 10)                 continue;                             //Get authid             new authid[33]             get_user_authid(id, authid, 32)                         //Containi is used since I'm not in the mood of stripping newlines             if(equal(authid , output))             {                 can_change[id] = true;              }         }     }     else     {         log_amx("%s not found" , filestr);     }         return PLUGIN_CONTINUE; }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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