AlliedModders

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

Dizzy 04-29-2006 22:04

Help with my plugin
 
Alright, this isn't a plugin test anymore, I guess I need help :(

Well here is what I have,

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> new bool:idtype[id] public plugin_init() {     register_plugin("Clan Models","0.1","Dizzy")     register_event("ResetHUD", "modelreset", "b")     new configsDir[64]     get_configsdir(configsDir, 63)     format(configsDir, 63, "%s/clan.cfg", configsDir)     return PLUGIN_HANDLED } public client_connect(id) {     idtype[id] = false } public client_disconnect(id) {     idtype[id] = false } public plugin_precache() {         precache_model("models/clanmodels/clanter.mdl")         precache_model("models/clanmodels/clanct.mdl")         return PLUGIN_CONTINUE } public modelreset(id, level, cid) {     new t_arg[16]     read_argv(4, t_arg, 15)     if (equali(t_arg, "steam") || equali(t_arg, "steamid") || equali(t_arg, "auth"))     {         idtype[id] = true     }     if (idtype[id] = true)     {         new CsTeams:userTeam = cs_get_user_team(id)         if (userTeam == CS_TEAM_T)         {             cs_set_user_model(id, "clanter")         }         if(userTeam == CS_TEAM_CT)         {             cs_set_user_model(id, "clanct")         }     } return PLUGIN_CONTINUE }

It is suppose to change the model of a person who is in the clan.cfg file...

So basically, you put a user's steamid into "clan.cfg" and when the round resets, their model changes to either clanter.mdl or clanct.mdl depending on what team they are on.

Thanks in advance guys!

v3x 04-29-2006 23:16

It's not going to work.

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> new bool:idtype[id] public plugin_init() {     register_plugin("Clan Models","0.1","Dizzy")     register_event("ResetHUD", "modelreset", "b")     new configsDir[64]     get_configsdir(configsDir, 63)     format(configsDir, 63, "%s/clan.cfg", configsDir)     loadSettings(configsDir) // this function doesn't exist!     return PLUGIN_HANDLED } public client_connect(id) {     idtype[id] = false } public client_disconnect(id) {     idtype[id] = false } public plugin_precache() {         precache_model("models/clanmodels/clanter.mdl")         precache_model("models/clanmodels/clanct.mdl")         return PLUGIN_CONTINUE } // You need to delay this slightly with a task and such public modelreset(id, level, cid) {     new t_arg[16]     read_argv(4, t_arg, 15) // what the hell is this? jibberish, eh?     if (equali(t_arg, "steam") || equali(t_arg, "steamid") || equali(t_arg, "auth"))     {         idtype[id] = true     }     if (idtype[id] = true)     {         new CSTEAMS:userTeam = cs_get_user_team(id) // it's CsTeams, not CSTEAMS         if (userTeam == CS_TEAM_T)         {             cs_set_user_model(id, "clanter")         }         if(userTeam == CS_TEAM_CT)         {                         cs_set_user_model(id, "clanct")         }     }     return PLUGIN_CONTINUE }
It needs some major work.

Moving this to "Scripting Help".

gene 04-30-2006 01:32

i have 4 and lots of players so ill help anyway i can. just pm me when/if ya need me

Dizzy 04-30-2006 16:02

Yeah, v3x I wasn't sure how to make it check a .cfg file for STEAM ID's listed...

I tried to look at the admin.sma that comes with amxmodx, but I guess I was extremely unsuccessful, halp plz! :(

v3x 04-30-2006 19:22

Look at my "Clan tag checker" plugin.

MaximusBrood 04-30-2006 19:26

Quote:

Originally Posted by Dizzy
Yeah, v3x I wasn't sure how to make it check a .cfg file for STEAM ID's listed...

I tried to look at the admin.sma that comes with amxmodx, but I guess I was extremely unsuccessful, halp plz! :(

Could you please tell us what you are trying to do, since I don't really see it :)

If you are trying to load things from a file:

Code:
//Load the data new filepath[64]; get_configsdir(filepath, 63); format(filepath, 63, "%s/myfile.cfg", filepath);     if(file_exists(filepath)) {     new output[128];         //Open file     new fHandle = fopen(filepath, "rt");         //Checks for failure     if(!fHandle)         return;         //Loop through all lines     for(new a = 0; !feof(fHandle); a++)     {         //Get line         fgets(fHandle, output, 511);         //PUT YOUR OWN CODE HERE <---     } }

Dizzy 05-01-2006 01:18

Alright, here's what I want, I want this plugin to check clanmodels.cfg for STEAM ID's and if your STEAM ID is in the clanmodels.cfg, it will change your CS model to either clanter.mdl or clanct.mdl depending on what Team you are on...

Here's what I have

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("Clan Models","0.1","Dizzy")     register_event("ResetHUD", "modelreset", "b")     return PLUGIN_HANDLED } public plugin_precache() {     precache_model("models/clanmodels/clanter.mdl")     precache_model("models/clanmodels/clanct.mdl")     return PLUGIN_CONTINUE } public modelreset(id, level, cid) {     new filepath[64]     get_configsdir(filepath, 63)     format(filepath, 63, "%s/clanmodels.cfg", filepath)     if(file_exists(filepath))     {         new output[128]         new fHandle = fopen(filepath, "rt")             if(!fHandle)             return                 for(new a = 0; !feof(fHandle); a++)             {             fgets(fHandle, output, 511)             new CsTeams:userTeam = cs_get_user_team(id)             if (userTeam == CS_TEAM_T)             {                 cs_set_user_model(id, "clanter")             }             if(userTeam == CS_TEAM_CT)             {                 cs_set_user_model(id, "clanct")             }         }     } return PLUGIN_HANDLED }

Thanks in advance =)

MaximusBrood 05-01-2006 08:12

Not tested, but it compiles okay :)

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("Clan Models","0.1","Dizzy")     register_event("ResetHUD", "modelreset", "b")     return PLUGIN_HANDLED } public plugin_precache() {     precache_model("models/clanter/clanter.mdl")     precache_model("models/clanct/clanct.mdl")     return PLUGIN_CONTINUE } public modelreset(id) {     //Get filepath     new filepath[64]     get_configsdir(filepath, 63)     format(filepath, 63, "%s/clanmodels.cfg", filepath)     if(file_exists(filepath))     {         new output[128]         new fHandle = fopen(filepath, "rt")         if(!fHandle)             return PLUGIN_CONTINUE         for(new a = 0; !feof(fHandle); a++)         {             //Get line             fgets(fHandle, output, 511)                 //Check if line is invalid             if(output[0] == ';' || !output[0] || output[0] == ' ' || output[0] == 10)                 continue;                             //Get authid             new authid[35]             get_user_authid(id, authid, 34)                         //Containi is used since I'm not in the mood of stripping newlines             if(containi(output, authid) != -1)             {                 new CsTeams:userTeam = cs_get_user_team(id)                         if (userTeam == CS_TEAM_T)                 {                     cs_set_user_model(id, "clanter")                 }                     if(userTeam == CS_TEAM_CT)                 {                     cs_set_user_model(id, "clanct")                 }               }         }     }         return PLUGIN_CONTINUE; }

One small note: Make sure the folder where de models are in is named the same as the model itself.

EG: models/clanter/clanter.mdl and NOT models/clanmodels/clanter.mdl
Same with the CT models offcourse

Good luck :D

v3x 05-01-2006 16:00

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; }

MaximusBrood 05-01-2006 17:22

That's right. But I was in a hurry when I made it :wink: (no exuse though =P)

[offtopic]BTW. Why are you doing me -3 karma hits every day V3X. Together with Su1cide[/offtopic]


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

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