Jump to content

Help with script


kuba90pl

Recommended Posts

Hello, i've got a problem with my script.

i made a function which count total player time in server and export it to a file

  
time_spend=0 
 function count(playerSource) 
time_spend=(time_spend)+1 
stat=fileOpen(" "..playerz.."_stats.txt")   
read_time=fileRead(stat,500) 
  
  
total_spend_time=read_time+time_spend 
    fileWrite(stat, ""..total_spend_time..":secs")   
     fileClose(stat)     
  
end 

and a file with stats look:(this is example)

  
123:secs 
  

i want to get only number (123) from file , not string ":secs" . How to make it?

help please!

Link to comment

okay i did this

  function count(playerSource) 
time_spend=(time_spend)+1 
stat=fileOpen(" "..playerz.."_stats.txt")   
read_time=fileRead(stat,500) 
  
done_time=gettok ( read_time ,1,  string.byte(':') ) 
total_time=done_time+time_spend 
outputChatBox(""..total_time.."") 
fileWrite(stat,""..total_time..":secs") 
     fileClose(stat)     
  
  
end 

and it save it as 123:secs124:secs124:secs...etc i want it to save only once like 124:secs then in next second 125:secs, not 123:secs124secs124secs

Link to comment

There is easier/safer ways of doing this, use setAccountData to save.

And make a timer that will increase the player minutes/seconds.

If seconds == 60 then increase the minutes

if minutes == 60 then increase the hours.

That's better.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...