SA-MP Forums Archive
[FilterScript] [FS] Windows or Linux detector - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [FS] Windows or Linux detector (/showthread.php?tid=79922)

Pages: 1 2


[FS] Windows or Linux detector - Vetle - 31.05.2009

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");
    }
}




Re: [FS] Windows or Linux detector - Backwardsman97 - 31.05.2009

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


Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

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?


Re: [FS] Windows or Linux detector - Weirdosport - 31.05.2009

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.




Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

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?


Re: [FS] Windows or Linux detector - Correlli - 31.05.2009

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


Re: [FS] Windows or Linux detector - NigNog1 - 31.05.2009

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


Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

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.


Re: [FS] Windows or Linux detector - Vetle - 31.05.2009

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

on linux GetTickCount() returns an negative number.


Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

Yeah,i got you now
For what you use this?


Re: [FS] Windows or Linux detector - Vetle - 31.05.2009

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


Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

On your home computer? Haha


Re: [FS] Windows or Linux detector - Correlli - 31.05.2009

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..


Re: [FS] Windows or Linux detector - NigNog1 - 31.05.2009

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.


Re: [FS] Windows or Linux detector - Luka P. - 31.05.2009

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.


Re: [FS] Windows or Linux detector - Weirdosport - 31.05.2009

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.


Re: [FS] Windows or Linux detector - yezizhu - 01.06.2009

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.


Re: [FS] Windows or Linux detector - Luka P. - 01.06.2009

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.


Re: [FS] Windows or Linux detector - yezizhu - 01.06.2009

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


Re: [FS] Windows or Linux detector - Joske_Vermeulen - 01.06.2009

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