Raised This Month: $ Target: $400
 0% 

client_authorized triggers twice?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-08-2007 , 14:22   client_authorized triggers twice?
Reply With Quote #1

Gah I'm really angry right now, because I've been making a simple* mind you simple plugin that redistributes weapons back to players on join.

Now I've tried setting tasks with "task_exists" and even global variables for stops....no matter what it always EXECUTES TWICE!?!?!?!? W#%(*@#(@$@(%#)$%
I've been working with this for over 2 hours and I'm really annoyed at this point.

Code:
public client_authorized(id) {     give_weapons(id+6500) } public give_weapons(id) {     id -= 6500     if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED     if(!is_user_connected(id) && !is_user_connecting(id))     {         remove_task(id+6500)         return PLUGIN_HANDLED     }     if(!is_user_alive(id))     {         //client_print(id,print_chat,"[WeaponSave] You have weapons pending. Please spawn immediately for re-distribution.")         set_task(5.0,"give_weapons",id+6500)         return PLUGIN_HANDLED     }     if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED     g_weapon_hold[id] = 1     format(g_Query[id],QUERY_MAX_USER-1,"SELECT WID,WClip,WAmmo,WMode,WAddons,WAddons_Active FROM users_weapons WHERE SteamID='%s'",g_SteamIDS[id])     result = dbi_query(dbc,"%s",g_Query[id])     if(dbi_nextrow(result) > 0)     {         new wid, clip, ammo, mode, extras, extras_active         new num_rows = dbi_num_rows(result)         for(new i=0; i < num_rows;i++)         {             wid = dbi_field(result,1)             clip = dbi_field(result,2)             ammo = dbi_field(result,3)             mode  = dbi_field(result,4)             extras  = dbi_field(result,5)             extras_active  = dbi_field(result,6)             client_print(id,print_console,"WID: %i",wid)             ts_giveweapon(id,wid,clip,extras)             dbi_nextrow(result)         }         client_cmd(id,"weapon_0")     }     dbi_free_result(result)     server_print("GIVEN")     g_weapon_hold[id] = 1     return PLUGIN_HANDLED }

Can anyone help me? Thanks.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
buskfaus
Junior Member
Join Date: Mar 2006
Old 02-08-2007 , 15:40   Re: client_authorized triggers twice?
Reply With Quote #2

Why don't you simply execute your give_weapons function on client_putinserver ? I think this may help you.
buskfaus is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 02-08-2007 , 17:32   Re: client_authorized triggers twice?
Reply With Quote #3

my only guess is that your server has sv_downloadurl enabled so the user connects once and the server checks for files, then forces the user to reconnect. At least, that's what I think happens, I don't use sv_downloadurl so I'm not too sure what happens.

In anycase, buskfaus is probably right, just use client_putinserver
lunarwolfx is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-08-2007 , 17:58   Re: client_authorized triggers twice?
Reply With Quote #4

client put in server doesn't work with TS correctly for some odd reason.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
stupok
Veteran Member
Join Date: Feb 2006
Old 02-08-2007 , 20:25   Re: client_authorized triggers twice?
Reply With Quote #5

In my experience I've never had a problem with client_putinserver() using TS.
stupok is offline
Old 02-10-2007, 01:42
mysticssjgoku4
This message has been deleted by Greentryst. Reason: bumping is not allowed until 2 weeks since last post in thread
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-10-2007 , 03:23   Re: client_authorized triggers twice?
Reply With Quote #7

I have a hunch. Try removing the give_weapons call and see if it still occurrs twice.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-14-2007 , 01:13   Re: client_authorized triggers twice?
Reply With Quote #8

Nope, I put a server_print() at the begining, and if its removed, it does nothing, if I put it in client_putinserver(id) it does it twice :S.
client_authorized(id) does the same, and does it twice.

Code:
public client_authorized(id) {     give_weap(id+6500)     return PLUGIN_HANDLED } public give_weap(id) {     server_print("triggered")     if(task_exists(id+6500)) id -= 6500         if(!is_user_connected(id) && !is_user_connecting(id))     {         remove_task(id+6500)         return PLUGIN_HANDLED     }     if(!is_user_alive(id) && !task_exists(id+6500))       {         //client_print(id,print_chat,"[WeaponSave] You have weapons pending. Please spawn immediately for re-distribution.")         set_task(5.0,"give_weap",id+6500)         return PLUGIN_HANDLED     }     if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED     format(g_Query[id],QUERY_MAX_USER-1,"SELECT WID,WClip,WAmmo,WMode,WAddons,WAddons_Active FROM users_weapons WHERE SteamID='%s'",g_SteamIDS[id])     result = dbi_query(dbc,"%s",g_Query[id])     if(dbi_nextrow(result) > 0)     {         new wid, clip, ammo, mode, extras, extras_active         new num_rows = dbi_num_rows(result)         for(new i=0; i < num_rows;i++)         {             if(g_weapon_hold[id] == 1) return PLUGIN_HANDLED             wid = dbi_field(result,1)             clip = dbi_field(result,2)             ammo = dbi_field(result,3)             mode  = dbi_field(result,4)             extras  = dbi_field(result,5)             extras_active  = dbi_field(result,6)             client_print(id,print_console,"WID: %i",wid)             ts_giveweapon(id,wid,clip,extras)             dbi_nextrow(result)         }         g_weapon_hold[id] = 1         client_cmd(id,"weapon_0")     }     dbi_free_result(result)     server_print("GIVEN")     g_weapon_hold[id] = 1     return PLUGIN_HANDLED }
__________________


Last edited by mysticssjgoku4; 02-14-2007 at 01:18.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 02-14-2007 , 01:25   Re: client_authorized triggers twice?
Reply With Quote #9

you want it where when a client spawns, they get a gun? because you cant give a user a gun when they "authorize", because they are not alive and or in game to recieve a gun. if i am correct, client authorized indicates that the steam id is validated…
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
BetaX
Member
Join Date: Nov 2005
Old 02-14-2007 , 03:02   Re: client_authorized triggers twice?
Reply With Quote #10

Code:
    if(task_exists(id+6500)) id -= 6500         if(!is_user_connected(id) && !is_user_connecting(id))     {         remove_task(id+6500)         return PLUGIN_HANDLED     }

Something feels wrong there.

I'm thinking that first 'task_exists' is wrong.
If the task does exist, do you want to do:

Code:
        id -= 6500

or do you want:

Code:
       remove_task(id+6500)

Also, should:

Code:
       if(!is_user_connected(id) && !is_user_connecting(id))

have its && changed to a ||?

I recommend writing out your thoughts on a piece of paper to clear out what makes sense and what does not. Draw a flowchart or something.

Edit: And for the sake of the processor, change all those id+6500's to a single variable equalling id + 6500... for whatever reason you are doing that.
BetaX 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 00:41.


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