AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simple error i guess (https://forums.alliedmods.net/showthread.php?t=12753)

Cronck 04-23-2005 20:22

Simple error i guess
 
When i client joins the game a timer should started for the specific player and run the function CreateStatus(id) every ½ second to make sure their xp info is 'up-2-date'.

How do i fix this?
Code:
public client_connect(id) {  set_task(0.5,CreateStatusText,id,_,_,"b") }

Edit:
I've also tried this code:
Code:
public client_connect(id) {      new sid[22]      num_to_str(id,sid,21)      set_task(0.5,"CreateStatusText",id,sid,21,"b") }

teame06 04-23-2005 20:45

remove_task to stop a task.

Cronck 04-23-2005 21:21

Ok, thanks...

But how do i make my task start correctly?

v3x 04-23-2005 21:29

It depends what you're trying to do.

BioHazardousWaste 04-23-2005 21:40

I had this problem too.. the problem is that the steamid is not authorized (so you don't know it) yet. So what I did was put all that code on round start like this.

Code:
public client_connect(id) {     SetUpUser(id) } public SetUpUser(id) {     PlayerAlliance[id] = 0     PlayerExp[id] = 0     ReadyToLoad[id] = 1 }

then this is executed at the beginning of every round

Code:
        for(new i=1;i<=32;i++)         {                         if(ReadyToLoad[i] == 1)             {                 ReadyToLoad[i] = 0                 SetUpNewUser(i)                          }                  }
Where SetUpNewUser is loading exp and such. Hope that helps, also I had to set a 0.3 second delay (set_task) to allow everyone time to spawn.

xeroblood 04-23-2005 21:44

I believe client_connect is deprecated, you should be using client_authorized(id) instead.. plus, the users steam id will have been auth'd by then, and you can use it..
I hope that helps..

Cronck 04-23-2005 22:02

Players on the server are given an Id (1-32)
Thats the id i use to store xp and such things in....

When the client connects to the server, it should start a task
that runs CreateStatusText(id) with the users id every ½ second...

No matter what i do, it wont work... :(

BioHazardousWaste 04-23-2005 22:04

Holy christ, don't do that or esle you will be playing for liek 3 weeks as id #3 then i will connect the next day s the third player (id #3) and get all your experience!!!! As for it not working, I dunno try xerobloods method, it's more politically correct, but mine works for me.

xeroblood 04-23-2005 22:21

Quote:

Originally Posted by Cronck
Players on the server are given an Id (1-32)
Thats the id i use to store xp and such things in....

I agree, bad idea.. use SteamID instead, it is the only truely unique ID for players to work with..

Quote:

Originally Posted by Cronck
When the client connects to the server, it should start a task
that runs CreateStatusText(id) with the users id every ½ second...

I smell lag!! Possibility of 32 functions running every 1/2 a second?!?!?! My advice: Show it to users only when the contents change!!

Cronck 04-23-2005 22:33

XP Will not be saved... :)
And its reset every single time a client connects too (for the client only)

I guess i will just put it into my Damage event then...


All times are GMT -4. The time now is 09:54.

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