AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem about read file and set someting? (https://forums.alliedmods.net/showthread.php?t=95756)

K.K.Lv 06-26-2009 21:41

Problem about read file and set someting?
 
hey !! guys!
how to make a plugin read file and set player model!
i just wrote one ,but can't be worked!
who can give me some example??
thanks all !!!

Arkshine 06-27-2009 02:40

Re: Problem about read file and set someting?
 
Since you're here to learn, show your code and we will tell you what's wrong.

K.K.Lv 06-27-2009 08:41

Re: Problem about read file and set someting?
 
oh! sorry, I forgot!:)
the code
PHP Code:

new configsdir[64]
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
set_task(60.0"set_model"___"b")
 
get_configsdir(configsdir63)
 
format(configsdir63"%s/plmodels.ini"configsdir)
}
public 
plugin_precache() {
 
precache_model("models/player/admin_ct/admin_ct.mdl")
 
precache_model("models/player/admin_te/admin_te.mdl")
}
public 
set_model(id) {
 new 
name[32], parsedmodels[32], readdata[128], parsedname[32]
 new 
txtlen
 get_user_name
(idname31)
 
 new 
line 0
 
while(!read_file(configsdirline++, 127txtlen)) {
  
parse(configsdirparsedname31parsedmodels31)
  if (
equal(nameparsedname) {
   
cs_set_user_model(idparsedmodels)
   break
  }
 }



zacky 06-27-2009 09:16

Re: Problem about read file and set someting?
 
First of all, your not using any index in the set_task, so you can't set model on the index since you don't have an index.

And it's better to set model in Ham_Spawn, and i see you are using 2 admin models, so you better check if player is an admin too...

K.K.Lv 06-27-2009 10:25

Re: Problem about read file and set someting?
 
can i do like this ?
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "Set Player Model"
#define VERSION "1.0"
#define AUTHOR "K.K.Lv"

new configsdir[64]
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
RegisterHam(Ham_Spawn"player""set_model")
 
get_configsdir(configsdir63)
 
format(configsdir63"%s/plmodels.ini"configsdir)
}
public 
plugin_precache() {
 
precache_model("models/player/admin_ct/admin_ct.mdl")
 
precache_model("models/player/admin_te/admin_te.mdl")
}
public 
set_model(id) {
 new 
name[32], parsedmodels[32], readdata[128], parsedname[32]
 new 
txtlen
 get_user_name
(idname31)
 
 new 
line 0
 
while(!read_file(configsdirline++, 127txtlen)) {
  
parse(configsdirparsedname31parsedmodels31)
  if (
equal(nameparsedname) {
   if (
get_user_flags(id) & ADMIN_KICK) {
    
cs_set_user_model(idparsedmodels)
    break
   }
  }
 }



zacky 06-27-2009 10:44

Re: Problem about read file and set someting?
 
Why don't you try?

micke1101 06-27-2009 13:30

Re: Problem about read file and set someting?
 
Quote:

Originally Posted by K.K.Lv (Post 858476)
can i do like this ?
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "Set Player Model"
#define VERSION "1.0"
#define AUTHOR "K.K.Lv"

new configsdir[64]
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
RegisterHam(Ham_Spawn"player""set_model")
 
get_configsdir(configsdir63)
 
format(configsdir63"%s/plmodels.ini"configsdir)
}
public 
plugin_precache() {
 
precache_model("models/player/admin_ct/admin_ct.mdl")
 
precache_model("models/player/admin_te/admin_te.mdl")
}
public 
set_model(id) {
 new 
name[32], parsedmodels[32], readdata[128], parsedname[32]
 new 
txtlen
 get_user_name
(idname31)
 
 new 
line 0
 
while(!read_file(configsdirline++, 127txtlen)) {
  
parse(configsdirparsedname31parsedmodels31)
  if (
equal(nameparsedname) {
   if (
get_user_flags(id) & ADMIN_KICK) {
    
cs_set_user_model(idparsedmodels)
    break
   }
  }
 }



Im not familiar with reading files but shouldnt you read the file before you try to use it?

fysiks 06-27-2009 13:36

Re: Problem about read file and set someting?
 
Quote:

Originally Posted by micke1101 (Post 858619)
Im not familiar with reading files but shouldnt you read the file before you try to use it?

Yeah, it should be cached. It will be much faster/efficient.


All times are GMT -4. The time now is 15:39.

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