Raised This Month: $ Target: $400
 0% 

Problem about read file and set someting?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 06-26-2009 , 21:41   Problem about read file and set someting?
Reply With Quote #1

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 !!!
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-27-2009 , 02:40   Re: Problem about read file and set someting?
Reply With Quote #2

Since you're here to learn, show your code and we will tell you what's wrong.
__________________
Arkshine is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 06-27-2009 , 08:41   Re: Problem about read file and set someting?
Reply With Quote #3

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

K.K.Lv is offline
Send a message via MSN to K.K.Lv
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-27-2009 , 09:16   Re: Problem about read file and set someting?
Reply With Quote #4

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...
zacky is offline
Send a message via Skype™ to zacky
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 06-27-2009 , 10:25   Re: Problem about read file and set someting?
Reply With Quote #5

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

K.K.Lv is offline
Send a message via MSN to K.K.Lv
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-27-2009 , 10:44   Re: Problem about read file and set someting?
Reply With Quote #6

Why don't you try?
zacky is offline
Send a message via Skype™ to zacky
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 06-27-2009 , 13:30   Re: Problem about read file and set someting?
Reply With Quote #7

Quote:
Originally Posted by K.K.Lv View Post
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?
micke1101 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-27-2009 , 13:36   Re: Problem about read file and set someting?
Reply With Quote #8

Quote:
Originally Posted by micke1101 View Post
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.
__________________
fysiks is offline
Reply



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 15:39.


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