Author Topic: Advanced Server Voting  (Read 1740 times)

Here's an improved server voting add-on I made from scratch.
The old one is buggy and not slick, so I made a new one. This one has statistics and stuff. You'll like it (i hope).
Commands:
/vote yes/no
/setvotetime number (in seconds)
/startvote blah blah blah
/endvote

Download
this was tested on an internet server with nobody online except me, if anything goes wrong please contact me and i will fix it. it SHOULD work.
« Last Edit: July 11, 2015, 11:28:09 PM by -Setro- »

Since you locked other thread about the isNumber function, I'll share you one that works well for me:
Code: [Select]
function isNumber(%n)
if(%n !$= %n * 1)
{
        return 0;
}
return 1;
}
Only caveat about it is that it won't work for larger numbers since numbers over 1 million get put in scientific notation and numbers that have over 6 digits in them (ex: -0.5312316) get shortened internally, so it's best used for integers or any other case that shouldn't need to have many digits.

jet fuel can't melt steel beams.

Since you locked other thread about the isNumber function, I'll share you one that works well for me:
Code: [Select]
function isNumber(%n)
if(%n !$= %n * 1)
{
        return 0;
}
return 1;
}
Only caveat about it is that it won't work for larger numbers since numbers over 1 million get put in scientific notation and numbers that have over 6 digits in them (ex: -0.5312316) get shortened internally, so it's best used for integers or any other case that shouldn't need to have many digits.

Code: [Select]
function isNumber(%n)
if(%n !$= (%n * 1) | 0)
{
        return 0;
}
return 1;
}

I haven't tested this but it should eliminate the caveat.

Code: [Select]
function isNumber(%n)
if(%n !$= (%n * 1) | 0)
{
        return 0;
}
return 1;
}

I haven't tested this but it should eliminate the caveat.

|0 casts to a signed int, so with the example -0.531 it'll give you 0. I'm not sure if that's important though.


Here you go

function isInfinity(%n) {
   return strcmp(%n, "-1.#INF") == 0 || strcmp(%n, "1.#INF") == 0;
}

function isNaN(%n) {
   return strcmp(%n, "-1.#IND") == 0;
}

function isFloat(%n) {
   return %n $= (%n + 0);
}

function isInteger(%n) {
   return %n $= (%n | 0);
}

function isFakeInt(%n) {
   return %n $= mFloor(%n);
}

function isNumber(%n) {
   return isInteger(%n) || isFloat(%n);
}

Here you go

function isInfinity(%n) {
   return strcmp(%n, "-1.#INF") == 0 || strcmp(%n, "1.#INF") == 0;
}

function isNaN(%n) {
   return strcmp(%n, "-1.#IND") == 0;
}

function isFloat(%n) {
   return %n $= (%n + 0);
}

function isInteger(%n) {
   return %n $= (%n | 0);
}

function isFakeInt(%n) {
   return %n $= mFloor(%n);
}

function isNumber(%n) {
   return isInteger(%n) || isFloat(%n);
}

thanks; OP should probably update his add-on to use these functions too

thanks; OP should probably update his add-on to use these functions too
everything in the add-on appears to be working seamlessly, if something goes wrong i will