AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Keeping track of reconnecting players before map change (https://forums.alliedmods.net/showthread.php?t=24413)

Lt Llama 02-22-2006 02:21

Keeping track of reconnecting players before map change
 
1 Attachment(s)
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

Kraugh 02-22-2006 14:41

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.

Lt Llama 02-22-2006 15:19

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 :D. I use contain in one place and equl in another, that why i confused them.

Lt Llama 02-23-2006 10:48

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.


All times are GMT -4. The time now is 20:26.

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