[FilterScript] [FS] Windows or Linux detector
#1

Simply tells you if you run on Windows or Linux.
I recomend adding to your gamemode.

FS version:
pawn Code:
#include <a_samp>

public OnFilterScriptInit()
{
    if(GetTickCount() > 0)
    {
      print("Running on Windows");
    }
    else
    {
      print("Running on Linux");
    }
}
GM version:
pawn Code:
#include <a_samp>

public OnGameModeInit()
{
    if(GetTickCount() > 0)
    {
      print("Running on Windows");
    }
    else
    {
      print("Running on Linux");
    }
}

Reply
#2

That's not an FS, it's a snippet. And how would you not know what OS your computer is running?
Reply
#3

Quote:
Originally Posted by Vetle
Simply tells you if you run on Windows or Linux.
I recomend adding to your gamemode.

FS version:
pawn Code:
#include <a_samp>

public OnFilterScriptInit()
{
    if(GetTickCount() > 0)
    {
      print("Running on Windows");
    }
    else
    {
      print("Running on Linux");
    }
}
GM version:
pawn Code:
#include <a_samp>

public OnGameModeInit()
{
    if(GetTickCount() > 0)
    {
      print("Running on Windows");
    }
    else
    {
      print("Running on Linux");
    }
}

lmao
how can you know what OS is player running with GetTickCount?
Reply
#4

Because it works on one and not on the other.

This could be useful when releasing a script that could potentially be used by either person, but if it's just a personal script I think you'd know what you were using.

Reply
#5

Quote:
Originally Posted by Weirdosport
Because it works on one and not on the other.

This could be useful when releasing a script that could potentially be used by either person, but if it's just a personal script I think you'd know what you were using.

1. You don`t know on what OS you runing your server?
2. Why this would be useful for scripting?
Reply
#6

This is only useful to check which OS is your server-hoster running. And is that so much important? I don't think so.
Reply
#7

GetTickCount works fine on Linux for me. I don't know if anyone else has problems though.
Reply
#8

Quote:
Originally Posted by Don Correlli
This is only useful to check which OS is your server-hoster running. And is that so much important? I don't think so.
How? You can`t view server running console on your host.
Reply
#9

GetTickCount() = Windows only.
tickcount() = Windows and Linux.

on linux GetTickCount() returns an negative number.
Reply
#10

Yeah,i got you now
For what you use this?
Reply
#11

Quote:
Originally Posted by Luka[balkan-samp.com
]
Yeah,i got you now
For what you use this?
to check if the server runs on windows or linux
Reply
#12

On your home computer? Haha
Reply
#13

Quote:
Originally Posted by Luka[balkan-samp.com
]
Quote:
Originally Posted by Don Correlli
This is only useful to check which OS is your server-hoster running. And is that so much important? I don't think so.
How? You can`t view server running console on your host.
Everything is saved to server_log.txt. Some hosters are offering FTP access to the server files, you could check the printed message in server_log.txt, but this isn't useful in anyway..
Reply
#14

Quote:
Originally Posted by Vetle
GetTickCount() = Windows only.
tickcount() = Windows and Linux.

on linux GetTickCount() returns an negative number.
What Linux version is that on? I've been using GetTickCount on my Linux server for quite a while and never experienced a problem with it.
Reply
#15

Quote:
Originally Posted by Stevelo
Quote:
Originally Posted by Vetle
GetTickCount() = Windows only.
tickcount() = Windows and Linux.

on linux GetTickCount() returns an negative number.
What Linux version is that on? I've been using GetTickCount on my Linux server for quite a while and never experienced a problem with it.
Try again.
Reply
#16

I don't think I explained it very well. If you made a script to releae on here, you want it to be versatile, so that windows and linux users can both use it without problems. If for some reason the script needed to be different for linux users, by working out when the script loads what they're on variables could be changed to activate linux parts of the script.
Reply
#17

Quote:
Originally Posted by Weirdosport
I don't think I explained it very well. If you made a script to releae on here, you want it to be versatile, so that windows and linux users can both use it without problems. If for some reason the script needed to be different for linux users, by working out when the script loads what they're on variables could be changed to activate linux parts of the script.
I prefer to #if LINUX #endif rather than if(LINUX){}.
If the server hoster doesn't care of efficient,this would be useful.
Reply
#18

Quote:
Originally Posted by yezizhu
Quote:
Originally Posted by Weirdosport
I don't think I explained it very well. If you made a script to releae on here, you want it to be versatile, so that windows and linux users can both use it without problems. If for some reason the script needed to be different for linux users, by working out when the script loads what they're on variables could be changed to activate linux parts of the script.
I prefer to #if LINUX #endif rather than if(LINUX){}.
If the server hoster doesn't care of efficient,this would be useful.
But you must have definition of LINUX,for now it is just a word in pawn.
Reply
#19

Quote Luka[balkan-samp.com]:
How about create an include,containg
#define WINDOWS (false)
#define LINUX (true)
.
That would be easily edited by hoster.
That's my opinion
Reply
#20

Quote:
Originally Posted by Luka[balkan-samp.com
]
Quote:
Originally Posted by Stevelo
Quote:
Originally Posted by Vetle
GetTickCount() = Windows only.
tickcount() = Windows and Linux.

on linux GetTickCount() returns an negative number.
What Linux version is that on? I've been using GetTickCount on my Linux server for quite a while and never experienced a problem with it.
Try again.
perhaps try again yourself

GetTickCount works fine on my Debian server @ serverffs
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)