Raised This Month: $ Target: $400
 0% 

Help with file-read


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grinf4ce
Senior Member
Join Date: May 2006
Old 12-05-2007 , 15:27   Help with file-read
Reply With Quote #1

Hello there,
i'm a new little coder and want to recode a plugin.
Its this: Hats

I tried to give every player a hat when he spawn first time on map.

Originalfunction of Hats:
PHP Code:
public Give_Hat(id)
{
    new 
smodelnum[5], name[32]
    
read_argv(1,name,31)
    
read_argv(2,smodelnum,4)
    
    new 
player cmd_target(id,name,2)
    if (!
player) {
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG)
        return 
PLUGIN_HANDLED
    
}
    
    new 
imodelnum = (str_to_num(smodelnum))
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED
    
    Set_Hat
(player,imodelnum,id)

    return 
PLUGIN_CONTINUE

But i only get the error "[HATS] Player With That Name Does not Exist" when i join the server and spawn the first time.
How i had to modify the command, which i send to client @ first spawn?
PHP Code:
 new nick[33]
 new 
model[2]
 
 
get_user_name (id,nick,32)
 
model "1"// Automatic Modelnr 1
 
 
client_cmd(id,"amx_givehat #%n %m",id,model
Can someone help a little Codingnoob? :-/
Please.

Greets, Grinf4ce
__________________
Grinf4ce is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-05-2007 , 18:29   Re: Help: A question to a clientcommand
Reply With Quote #2

Code:
client_cmd(id,"amx_givehat %s %s",nick,model)

Last edited by Emp`; 12-05-2007 at 20:43.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-05-2007 , 18:55   Re: Help: A question to a clientcommand
Reply With Quote #3

PHP Code:
client_cmd(id,"amx_givehat #%d %s",get_user_userid(id),model

This will work better, as if you use id, you probably won't get the right person or a person at all
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Grinf4ce
Senior Member
Join Date: May 2006
Old 12-06-2007 , 01:07   Re: Help: A question to a clientcommand
Reply With Quote #4

Thank you YamiKoitou!
Works :-D

But Now the Bots havent a hat, when they join the server. :-/
Is the get_user_userid(id) only for humanplayer or havent bots the "first spawn" event?
__________________

Last edited by Grinf4ce; 12-06-2007 at 01:13.
Grinf4ce is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-06-2007 , 01:19   Re: Help: A question to a clientcommand
Reply With Quote #5

If the bots are not getting a hat, I would look at the hats plugin. It may be blocking it if it is trying to give one to a bot
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-06-2007 , 04:16   Re: Help: A question to a clientcommand
Reply With Quote #6

If you are hooking ResetHUD then no, bots don't have a spawn event.

Use register_forward(FM_Spawn,...) (FakeMeta)
or RegisterHam(Ham_Spawn,"player",...) (HamSandwich)
purple_pixie is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-07-2007 , 00:30   Re: Help: A question to a clientcommand
Reply With Quote #7

Quote:
Originally Posted by purple_pixie View Post
If you are hooking ResetHUD then no, bots don't have a spawn event.
yes they do.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-07-2007 , 04:28   Re: Help: A question to a clientcommand
Reply With Quote #8

Well I just played around with this:

Code:
#include <amxmodx> #include <amxmisc> #include <famekmeta> stock pixie_createbot() {     return pixie_createnamedbot("player_npc") } // creates a bot called <name> // returns player id stock pixie_createnamedbot(name[]) {     new bot=engfunc(EngFunc_CreateFakeClient,name)     new arr[128]     dllfunc(DLLFunc_ClientConnect, bot,name,"127.0.0.1",arr)     dllfunc(DLLFunc_ClientPutInServer, bot)     set_pev(bot,pev_spawnflags, pev(bot,pev_spawnflags) | FL_FAKECLIENT)     set_pev(bot,pev_flags, pev(bot,pev_flags) | FL_FAKECLIENT)     cs_set_user_team(bot,CS_TEAM_CT,CS_CT_GSG9 )     spawn(bot)     spawn(bot)     spawn(bot)     return bot } public plugin_init() {     register_plugin("Reset that Hud to them", "1.0", "Pixie")     register_event("ResetHUD","on_hudreset","b") ;     register_event("ResetHUD","on_globalhudreset","c") ;     register_srvcmd("pixie","pixie") ; } public on_hudreset() {     log_amx("Omg! Some noob reset my HUD!") ; } public on_globalhudreset() {     log_amx("Omg! Some noob reset all our HUD's!") ; } new players[32] ; new playercount ; public pixie() {     players[playercount++] = pixie_createbot()     for ( new i ; i < playercount ; i ++ )     {         spawn(players[i]) ;     } }

And it only logged anything when I called sv_restartound
(When I called it, not when the round restarted - call sv_restartround 10 and it's obvious when it occurs)
purple_pixie is offline
Grinf4ce
Senior Member
Join Date: May 2006
Old 12-07-2007 , 12:58   Re: Help: A question to a clientcommand
Reply With Quote #9

Okay now it works.

But i have again a little noob question.
I wrote an addon which write the steamid in a file.

Now i want to read it out, and search for the steamid, which you use.
If the script found your id, you cant pick up the gift, else you can pickup the gift.

PHP Code:
    new readdata[128],steamid[32],txtlen;
    new 
parsedsteamid[32];
    
    
get_user_authid(id,steamid,31);
    
    new 
fsize file_size(filename,1);
    new 
status[2];

    for (new 
line=0;line<=fsize;line++)
    {
        
read_file(filename,line,readdata,127,txtlen); // Datei auslesen
        
parse(readdata,parsedsteamid,31); // Parsen
        
        
if(equal(steamid,parsedsteamid)) // Überprüfen ob Daten gleich sind..
        
{
            
client_print(id,print_chat,"* Sorry, but you cant pickup this gift!.");
            
status "1";
            break;
        }
        else
        {
            
status "0";
        }
    }
    
    if(
status "0")
    {
        
client_cmd(id,"amx_register");
        
remove_entity(pTouched);
    } 
But it doesnt work, you can pickup the gift again and again, and it wrote again and again in the file :-/

Oh man my bad english, i hope someone understand what i mean *g*
__________________
Grinf4ce is offline
Reply


Thread Tools
Display Modes

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 11:09.


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