Regarding fseek()
#1

Hey guys, I was curious about pawn's fseek function so I thought I'd ask here.

Is it possible to make a command that searches through all ini files until it finds a certain value?

Let's say I want to make a /listallcops command for admins, it would list every single cop regardless if they're offline. I've been trying to make this for a while now but I didn't get any luck.

Basically I want it to go through every single ini file until it finds the value that I want, and I want it to do this without completely crashing the server lol.

Help would be appreciated.
Reply
#2

Oh also I have one more question regarding files. I'm not going to make a new thread for it so I'll just post here.

I just made a new system that detects how long a player has been offline, it uses gettime() on disconnect and stores it as "DiscTime" in their ini file, and I made a command that does gettime() - <playerfilegettime> and it returns how many seconds they've been offline.

One problem though, I used this command on a player that doesn't have "DiscTime" created in their ini file, and it crashed my server. I use dini to get values and it works perfectly.

What would I need to use to see if they have "DiscTime" created in their ini file? fseek? fread?
Reply
#3

I'm afraid that is not possible, only in SQL. I recommand you changing to it.
If you still wan't to stay with file function do this:
create a file, where all cops will be listed.
When a cop starts working insert his name in to the file.
When he stops working - remove his name.
And i think you can make the check yourself.

Quote:
Originally Posted by xxxDunecatxxx
Посмотреть сообщение
Oh also I have one more question regarding files. I'm not going to make a new thread for it so I'll just post here.

I just made a new system that detects how long a player has been offline, it uses gettime() on disconnect and stores it as "DiscTime" in their ini file, and I made a command that does gettime() - <playerfilegettime> and it returns how many seconds they've been offline.

One problem though, I used this command on a player that doesn't have "DiscTime" created in their ini file, and it crashed my server. I use dini to get values and it works perfectly.

What would I need to use to see if they have "DiscTime" created in their ini file? fseek? fread?
I use dini for that.
pawn Код:
new disctime = dini_Int(file,"DiscTime");
            if(!disctime) return 0;
Reply
#4

Alright, thanks for the help.

What do you guys think of me storing their FactionMember value in some database using HTTP? Even though its stored in ini, I thought about storing it in HTTP as well just so I could grab a list of everyone who's a cop.
Reply
#5

why not in MySQL?
Reply
#6

HTTP is the same thing as MySQL except its made by SAMP themselves
Reply
#7

Quote:
Originally Posted by xxxDunecatxxx
Посмотреть сообщение
HTTP is the same thing as MySQL except its made by SAMP themselves
Good one haha.
Reply
#8

If you think about it, it really is. I use HTTP to store things into a ****** appengine database like player IP addresses and usernames just to expirement with them and they work similar to MySQL since you can use GQL to submit queries
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)