Raised This Month: $ Target: $400
 0% 

Keeping track of reconnecting players before map change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-22-2006 , 02:21   Keeping track of reconnecting players before map change
Reply With Quote #1

Ok, thats it, my eyes are like footballs after trying to find the reason of a bug in my script. A lot of stuff is going on and working, except for keeping track of returning players.

When a player triggers a goal model his authid is saved in the array finishContainer in function goal_touch.

When someone is connecting a client_authorized loops through finishContainer to see if the player reconnected.

Its a random error, sometimes it works, and sometimes not.

finishContainer is a global array defined

Code:
new finishContainer[maxUserid][32]

The authid is saved in function goal_touch

Code:
finishContainer[curId] = authid

And the loop in

Code:
// Check if its the first time before a map change a player connects // and if the player has already triggered the goal. public client_authorized(id) {     new authid[32]     get_user_authid(id,authid,31)         // Loop through the array of id's     new reconnected = 0     // Check if a player who finished is coming back     for (new loopId = 0; loopId < curId ; loopId++) {         if (equali(finishContainer[loopId],authid) != -1) {             set_task(30.0, "msgToReconnect",id)             reconnected = 1             hasFinished[id] = true         }     }     if (reconnected == 0)         set_task(30.0, "msgToNewPlayer",id)     return PLUGIN_CONTINUE }

If the authid is stored in finishContainer it calls msgToReconnect, which shows a welcome back message. But, it do it with new players to sometimes. In these cases finishContainer[loopId] = 0.

How can finishContainer[loopId] which is 0 be equal to authid
which clearly contains the authid?

Am I doing something wrong returning the array content from goal_touch?

I would really appreciate help with this problem. Its one of the last parts before cleaning it up and releasing it.

Thx

/Lt
Attached Files
File Type: sma Get Plugin or Get Source (skillsrank.sma - 559 views - 47.6 KB)
Lt Llama is offline
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 02-22-2006 , 14:41  
Reply With Quote #2

equali returns 0 if it didn't find anything, 1 if it did. you are checking to see if it does not equal -1, so this condition will always return true. you are confusing this with containi in which it returns -1 when nothing is found but sometimes 0 if something is.
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-22-2006 , 15:19  
Reply With Quote #3

Quote:
Originally Posted by Kraugh
equali returns 0 if it didn't find anything, 1 if it did. you are checking to see if it does not equal -1, so this condition will always return true. you are confusing this with containi in which it returns -1 when nothing is found but sometimes 0 if something is.
You read me like an open book. If it works now im gonna name a kid after you . I use contain in one place and equl in another, that why i confused them.
Lt Llama is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-23-2006 , 10:48  
Reply With Quote #4

Code:
// Check if its the first time before a map change a player connects // and if the player has already triggered the goal. public client_authorized(id) {     new authid[32]     get_user_authid(id,authid,31)         // Loop through the array of id's     new reconnected = 0     // Check if a player who finished is coming back     for (new loopId = 1; loopId <= curId; loopId++) {         if (equali(finishContainer[loopId],authid) == 1) {             set_task(30.0, "msgToReconnect",id)             reconnected = 1             hasFinished[id] = true         }     }     if (reconnected == 0)         set_task(30.0, "msgToNewPlayer",id)     return PLUGIN_CONTINUE }

Solved

Changed the for loop. Slot 0 of finishContainer[loopId] was empty. The for loop never reached 1. Probably something I should know with arrays, but well, i learned now.
Lt Llama 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 17:53.


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