Useful Functions

Quote:
Originally Posted by Lokii
View Post
PHP Code:
precent(Float:minFloat:max)
{
    return 
_:(floatabs((min/max)*100));

  1. The name of the first argument doesn't make any sense in this context and the second one is only a bit better.
  2. Quote:
    Originally Posted by Merriam-Webster dictionary
    Precent definition is - to act as precentor: lead a choir or congregation in singing.
  3. You are multiplying a float by an integer, the runtime has to cast the integer to a float, producing unnecessary overhead.
  4. De-tagging a float doesn't round it, the function will just return a value that's meaningless in this context. I wouldn't even round it since the user might need the extra precision.
  5. Getting the absolute value doesn't make much sense either. If someone uses the function with values with different signs, they probably have a reason.
PHP Code:
Float:percentage(Float:valueFloat:max_value) {
    return (
value max_value) * 100.0;

Reply

PlayerPlaySoundForAll function.


PHP Code:
PlayerPlaySoundForAll(soundidFloat:xFloat:yFloat:z)
{
   for(new 
0MAX_PLAYERSi++)
   {
    
PlayerPlaySound(i,soundid,Float:xFloat:yFloat:z);
   }
   return 
1;

Reply

PHP Code:
Float:FloatClamp(Float:valueFloat:minFloat:max)
{
    if(
value min || value max)
    {
        if(
value min) return min;
        if(
value max) return max;
    }
    return 
value;

Reply

Actually that is the perfect candidate for the ternary operator.

Besides that, you should forward Float Tag Functions.
Otherwise you had always to declare them, before you use them, for the sake of the compiler.

PHP Code:
forward Float:FloatClamp(Float:vFloat:minFloat:max);
stock Float:FloatClamp(Float:vFloat:minFloat:max)
{
    return 
min min : (max max v);

Reply

MessageKick(playerid, message[], (mixed));
Based on SendClientMessageEx function:
https://forum.sa-mp.com/showpost.php...postcount=4529

Usage:
PHP Code:
public OnPlayerConnect(playerid)
{
        
MessageKick(playerid"You're not worth to join %s server"SERVER_NAME);
        return 
1;

Code:
PHP Code:
stock MessageKick(playerid, const message[], {Float_}:...)
{
    static
        
args,
        
str[144];
    
/*
     *  Custom function that uses #emit to format variables into a string.
     *  This code is very fragile; touching any code here will cause crashing!
    */
    
if ((args numargs()) == 2)
    {
        
SendClientMessage(playerid0xFFFFFFAAmessage);
        
SetTimerEx("Kick"200false"i"playerid);
    }
    else
    {
        while (--
args >= 2)
        {
            
#emit LCTRL 5
            #emit LOAD.alt args
            #emit SHL.C.alt 2
            #emit ADD.C 12
            #emit ADD
            #emit LOAD.I
            #emit PUSH.pri
        
}
        
#emit PUSH.S message
        #emit PUSH.C 144
        #emit PUSH.C str
        #emit LOAD.S.pri 8
        #emit ADD.C 4
        #emit PUSH.pri
        #emit SYSREQ.C format
        #emit LCTRL 5
        #emit SCTRL 4
        
SendClientMessage(playerid0xFFFFFFAAstr);
        
SetTimerEx("Kick"200false"i"playerid);
        
#emit RETN
    
}
    return 
1;

You can change the amount ms to 500 or 10000000 if Kick with 200ms still won't show a message.

----
GenerateVoucher(output[])
This function can create a voucher like:
VOC-2FE3-JB2E-EK56-AB2T-R32F

Usage:
PHP Code:
CMD:createvoucher(playeridparams[])
{  
    new 
str[64];
  
    
GenerateVoucher(str);
    
format(strsizeof(str), "Successfully created a voucher (%s)"str);
    
SendClientMessage(playeridstr);
    return 
1;

Code:
PHP Code:
stock GenerateVoucher(output[])
{    
    new 
emee[25], total;
    for(new 
sa 0sa sizeof(emee); sa++) 
    {
        
total sa 5;
        
emee[sa] = random(2) ? (random(26) + 'A') : (random(10) + '0');
        if(
total == && emee[sa] != EOS) {
            
emee[sa] = '-';
        }
       }
    
format(outputsizeof(emee)+4"VOC%s"emee);
    return 
1;

Reply

IsValidSound(soundid)
  • soundid The id of the sound
Returns
  • 0 Sound ID is invalid
  • 1 Sound ID is valid
Check if a sound id or game audio id is valid (known), code is at the bottom of this post

Based on modified method of IsValidObject by y-!more and bits builder by Slice's on this topic:
https://sampforum.blast.hk/showthread.php?tid=352279
The sound id data source: http://pastebin.com/A1PbQZPd by Austin and LaZ (as seen in https://sampwiki.blast.hk/wiki/Sound_IDs) MERGED with the AudioEvents.txt list in GTA:SA data folder.

The differences i could see is that sound id 1190 is missing from AudioEvents while an ambient sound id 22600 is not in the pastebin. Some of audio events from 1000 to 1800 are also abstain from the pastebin because it's used in single player only (i.e. in minigames, arcades, or cutscenes), but i assume these id are safe anyway.

Note as of R2 client update, sound id ranging from 0 to 1000 are also included (they are not listed in the current pastebin and AudioEvents).

Even though i know that sa-mp client will not crash when passing invalid sound id between the range 0 to 45400 already (only silent), this may be still useful for people who'd like to keep this in the script/server data.
So, you do not really need this.

At first i did it so rough like this:
Code:
// DO NOT USE, THIS IS JUST EXAMPLE OF BAD IMPLEMENTATION
IsValidSoundSlow(soundid)
{
	if (0 <= soundid <= 1190) return 1;
	if (1800 <= soundid <= 1829) return 1;
	if (2000 <= soundid <= 2163) return 1;
	if (2200 <= soundid <= 2214) return 1;
	if (2400 <= soundid <= 2404) return 1;
	if (2600 <= soundid <= 2608) return 1;
	if (2800 <= soundid <= 2813) return 1;
	if (3000 <= soundid <= 3057) return 1;
	if (3200 <= soundid <= 3201) return 1;
	if (3400 <= soundid <= 3401) return 1;
	if (soundid == 3600) return 1;
	if (soundid == 3800) return 1;
	if (4000 <= soundid <= 4001) return 1;
	if (4200 <= soundid <= 4203) return 1;
	if (soundid == 4400) return 1;
	if (4600 <= soundid <= 4604) return 1;
	if (4800 <= soundid <= 4807) return 1;
	if (5000 <= soundid <= 5014) return 1;
	if (5200 <= soundid <= 5206) return 1;
	if (5400 <= soundid <= 5464) return 1;
	if (5600 <= soundid <= 5602) return 1;
	if (5800 <= soundid <= 5856) return 1;
	if (6000 <= soundid <= 6003) return 1;
	if (6200 <= soundid <= 6205) return 1;
	if (6400 <= soundid <= 6402) return 1;
	if (6600 <= soundid <= 6603) return 1;
	if (6800 <= soundid <= 6802) return 1;
	if (7000 <= soundid <= 7066) return 1;
	if (7200 <= soundid <= 7239) return 1;
	if (7400 <= soundid <= 7421) return 1;
	if (7600 <= soundid <= 7612) return 1;
	if (7800 <= soundid <= 7902) return 1;
	if (8000 <= soundid <= 8017) return 1;
	if (8200 <= soundid <= 8278) return 1;
	if (8400 <= soundid <= 8412) return 1;
	if (8600 <= soundid <= 8738) return 1;
	if (8800 <= soundid <= 8840) return 1;
	if (9000 <= soundid <= 9031) return 1;
	if (9200 <= soundid <= 9201) return 1;
	if (9400 <= soundid <= 9451) return 1;
	if (9600 <= soundid <= 9676) return 1;
	if (9800 <= soundid <= 9914) return 1;
	if (10000 <= soundid <= 10015) return 1;
	if (10200 <= soundid <= 10214) return 1;
	if (10400 <= soundid <= 10409) return 1;
	if (10600 <= soundid <= 10663) return 1;
	if (10800 <= soundid <= 10832) return 1;
	if (11000 <= soundid <= 11010) return 1;
	if (soundid == 11200) return 1;
	if (11400 <= soundid <= 11455) return 1;
	if (11600 <= soundid <= 11655) return 1;
	if (11800 <= soundid <= 11855) return 1;
	if (12000 <= soundid <= 12055) return 1;
	if (12200 <= soundid <= 12201) return 1;
	if (12400 <= soundid <= 12411) return 1;
	if (12600 <= soundid <= 12605) return 1;
	if (12800 <= soundid <= 12832) return 1;
	if (13000 <= soundid <= 13038) return 1;
	if (13200 <= soundid <= 13216) return 1;
	if (13400 <= soundid <= 13419) return 1;
	if (13600 <= soundid <= 13646) return 1;
	if (13800 <= soundid <= 13803) return 1;
	if (14000 <= soundid <= 14041) return 1;
	if (soundid == 14200) return 1;
	if (14400 <= soundid <= 14410) return 1;
	if (soundid == 14600) return 1;
	if (soundid == 14800) return 1;
	if (15000 <= soundid <= 15028) return 1;
	if (15200 <= soundid <= 15258) return 1;
	if (15400 <= soundid <= 15408) return 1;
	if (15600 <= soundid <= 15603) return 1;
	if (15800 <= soundid <= 15950) return 1;
	if (16000 <= soundid <= 16018) return 1;
	if (soundid == 16200) return 1;
	if (16400 <= soundid <= 16504) return 1;
	if (16600 <= soundid <= 16614) return 1;
	if (16800 <= soundid <= 16803) return 1;
	if (17000 <= soundid <= 17006) return 1;
	if (soundid == 17200) return 1;
	if (17400 <= soundid <= 17455) return 1;
	if (17600 <= soundid <= 17622) return 1;
	if (17800 <= soundid <= 17807) return 1;
	if (18000 <= soundid <= 18025) return 1;
	if (18200 <= soundid <= 18216) return 1;
	if (18400 <= soundid <= 18434) return 1;
	if (18600 <= soundid <= 18616) return 1;
	if (18800 <= soundid <= 18807) return 1;
	if (19000 <= soundid <= 19135) return 1;
	if (19200 <= soundid <= 19219) return 1;
	if (19400 <= soundid <= 19403) return 1;
	if (19600 <= soundid <= 19604) return 1;
	if (soundid == 19800) return 1;
	if (20000 <= soundid <= 20072) return 1;
	if (20200 <= soundid <= 20248) return 1;
	if (20400 <= soundid <= 20424) return 1;
	if (soundid == 20600) return 1;
	if (20800 <= soundid <= 20804) return 1;
	if (21000 <= soundid <= 21002) return 1;
	if (21200 <= soundid <= 21207) return 1;
	if (21400 <= soundid <= 21456) return 1;
	if (21600 <= soundid <= 21666) return 1;
	if (21800 <= soundid <= 21808) return 1;
	if (22000 <= soundid <= 22039) return 1;
	if (22200 <= soundid <= 22217) return 1;
	if (22400 <= soundid <= 22406) return 1;
	if (soundid == 22600) return 1;
	if (22800 <= soundid <= 22839) return 1;
	if (soundid == 23000) return 1;
	if (23200 <= soundid <= 23209) return 1;
	if (soundid == 23400) return 1;
	if (soundid == 23600) return 1;
	if (23800 <= soundid <= 23835) return 1;
	if (24000 <= soundid <= 24063) return 1;
	if (24200 <= soundid <= 24219) return 1;
	if (24400 <= soundid <= 24433) return 1;
	if (soundid == 24600) return 1;
	if (24800 <= soundid <= 24829) return 1;
	if (25000 <= soundid <= 25047) return 1;
	if (25200 <= soundid <= 25319) return 1;
	if (25400 <= soundid <= 25423) return 1;
	if (25600 <= soundid <= 25604) return 1;
	if (25800 <= soundid <= 25801) return 1;
	if (26000 <= soundid <= 26009) return 1;
	if (26200 <= soundid <= 26223) return 1;
	if (26400 <= soundid <= 26412) return 1;
	if (26600 <= soundid <= 26633) return 1;
	if (26800 <= soundid <= 26811) return 1;
	if (27000 <= soundid <= 27018) return 1;
	if (27200 <= soundid <= 27205) return 1;
	if (27400 <= soundid <= 27422) return 1;
	if (27600 <= soundid <= 27621) return 1;
	if (27800 <= soundid <= 27833) return 1;
	if (soundid == 28000) return 1;
	if (28200 <= soundid <= 28204) return 1;
	if (28400 <= soundid <= 28427) return 1;
	if (28600 <= soundid <= 28622) return 1;
	if (28800 <= soundid <= 28811) return 1;
	if (29000 <= soundid <= 29155) return 1;
	if (29200 <= soundid <= 29217) return 1;
	if (29400 <= soundid <= 29413) return 1;
	if (29600 <= soundid <= 29665) return 1;
	if (29800 <= soundid <= 29825) return 1;
	if (30000 <= soundid <= 30082) return 1;
	if (30200 <= soundid <= 30221) return 1;
	if (30400 <= soundid <= 30416) return 1;
	if (soundid == 30600) return 1;
	if (30800 <= soundid <= 30803) return 1;
	if (31000 <= soundid <= 31001) return 1;
	if (31200 <= soundid <= 31205) return 1;
	if (soundid == 31400) return 1;
	if (31600 <= soundid <= 31605) return 1;
	if (31800 <= soundid <= 31810) return 1;
	if (soundid == 32000) return 1;
	if (32200 <= soundid <= 32201) return 1;
	if (32400 <= soundid <= 32402) return 1;
	if (soundid == 32600) return 1;
	if (32800 <= soundid <= 32847) return 1;
	if (33000 <= soundid <= 33088) return 1;
	if (33200 <= soundid <= 33304) return 1;
	if (33400 <= soundid <= 33403) return 1;
	if (33600 <= soundid <= 33676) return 1;
	if (33800 <= soundid <= 33889) return 1;
	if (34000 <= soundid <= 34067) return 1;
	if (34200 <= soundid <= 34273) return 1;
	if (34400 <= soundid <= 34415) return 1;
	if (34600 <= soundid <= 34606) return 1;
	if (34800 <= soundid <= 34831) return 1;
	if (35000 <= soundid <= 35075) return 1;
	if (35200 <= soundid <= 35240) return 1;
	if (35400 <= soundid <= 35488) return 1;
	if (35600 <= soundid <= 35733) return 1;
	if (35800 <= soundid <= 35883) return 1;
	if (soundid == 36000) return 1;
	if (36200 <= soundid <= 36205) return 1;
	if (36400 <= soundid <= 36401) return 1;
	if (36600 <= soundid <= 36604) return 1;
	if (36800 <= soundid <= 36860) return 1;
	if (37000 <= soundid <= 37035) return 1;
	if (37200 <= soundid <= 37245) return 1;
	if (37400 <= soundid <= 37494) return 1;
	if (37600 <= soundid <= 37681) return 1;
	if (37800 <= soundid <= 37873) return 1;
	if (38000 <= soundid <= 38060) return 1;
	if (38200 <= soundid <= 38238) return 1;
	if (38400 <= soundid <= 38471) return 1;
	if (38600 <= soundid <= 38644) return 1;
	if (38800 <= soundid <= 38854) return 1;
	if (39000 <= soundid <= 39078) return 1;
	if (39200 <= soundid <= 39223) return 1;
	if (39400 <= soundid <= 39413) return 1;
	if (39600 <= soundid <= 39667) return 1;
	if (39800 <= soundid <= 39815) return 1;
	if (soundid == 40000) return 1;
	if (40200 <= soundid <= 40238) return 1;
	if (40400 <= soundid <= 40408) return 1;
	if (soundid == 40600) return 1;
	if (40800 <= soundid <= 40820) return 1;
	if (41000 <= soundid <= 41042) return 1;
	if (41200 <= soundid <= 41272) return 1;
	if (41400 <= soundid <= 41432) return 1;
	if (41600 <= soundid <= 41604) return 1;
	if (soundid == 41800) return 1;
	if (42000 <= soundid <= 42011) return 1;
	if (42200 <= soundid <= 42208) return 1;
	if (42400 <= soundid <= 42424) return 1;
	if (42600 <= soundid <= 42601) return 1;
	if (42800 <= soundid <= 42803) return 1;
	if (43000 <= soundid <= 43001) return 1;
	if (43200 <= soundid <= 43206) return 1;
	if (43400 <= soundid <= 43407) return 1;
	if (43600 <= soundid <= 43664) return 1;
	if (43800 <= soundid <= 43905) return 1;
	if (44000 <= soundid <= 44107) return 1;
	if (44200 <= soundid <= 44247) return 1;
	if (44400 <= soundid <= 44444) return 1;
	if (44600 <= soundid <= 44631) return 1;
	if (44800 <= soundid <= 44820) return 1;
	if (45000 <= soundid <= 45011) return 1;
	if (45200 <= soundid <= 45255) return 1;
	if (soundid == 45400) return 1;
	return 0;
}
I know some of you guys would suggest using || and single return, but that gave me compilation error of staging buffer (102).

But then i decide to use Slice implementation, converted it as list, printing each id as binary, and converted it to decimal, there are 8072 ids so it turns out like this (1419 cells):
Code:
// USE THIS ONE, it is optimized
stock IsValidSound(soundid)
{
	static const audiodat[] =
	{
		-1, -1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1, -1,
		-1, 127, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, -256, 63, 0, 0, 0, 0, -65536,
		-1, -1, -1, -1, 1048575, -16777216, 127, 0, 0,
		0, 0, 0, 31, 0, 0, 0, 0, 0,
		130816, 0, 0, 0, 0, 0, 1073676288, 0, 0,
		0, 0, 0, -16777216, -1, 262143, 0, 0, 0,
		0, 3, 0, 0, 0, 0, 0, 768, 0,
		0, 0, 0, 0, 65536, 0, 0, 0, 0,
		0, 16777216, 0, 0, 0, 0, 0, 0, 3,
		0, 0, 0, 0, 0, 3840, 0, 0, 0,
		0, 0, 65536, 0, 0, 0, 0, 0, 520093696,
		0, 0, 0, 0, 0, 0, 255, 0, 0,
		0, 0, 0, 8388352, 0, 0, 0, 0, 0,
		8323072, 0, 0, 0, 0, 0, -16777216, -1, 33554431,
		0, 0, 0, 0, 7, 0, 0, 0, 0,
		0, -256, -1, 1, 0, 0, 0, 983040, 0,
		0, 0, 0, 0, 1056964608, 0, 0, 0, 0,
		0, 0, 7, 0, 0, 0, 0, 0, 3840,
		0, 0, 0, 0, 0, 458752, 0, 0, 0,
		0, 0, -16777216, -1, 134217727, 0, 0, 0, 0,
		-1, 255, 0, 0, 0, 0, 1073741568, 0, 0,
		0, 0, 0, 536805376, 0, 0, 0, 0, 0,
		-16777216, -1, -1, cellmax, 0, 0, 0, 262143, 0,
		0, 0, 0, 0, -256, -1, 8388607, 0, 0,
		0, 536805376, 0, 0, 0, 0, 0, -16777216, -1,
		-1, -1, -1, 7, 0, -1, 511, 0, 0,
		0, 0, -256, 255, 0, 0, 0, 0, 196608,
		0, 0, 0, 0, 0, -16777216, -1, 4095, 0,
		0, 0, 0, -1, -1, 8191, 0, 0, 0,
		-256, -1, -1, 134217727, 0, 0, -65536, 0, 0,
		0, 0, 0, -16777216, 127, 0, 0, 0, 0,
		0, 1023, 0, 0, 0, 0, 0, -256, -1,
		255, 0, 0, 0, -65536, 131071, 0, 0, 0,
		0, -16777216, 7, 0, 0, 0, 0, 0, 1,
		0, 0, 0, 0, 0, -256, -1, 0, 0,
		0, 0, -65536, -1, 255, 0, 0, 0, -16777216,
		-1, 65535, 0, 0, 0, 0, -1, 16777215, 0,
		0, 0, 0, 768, 0, 0, 0, 0, 0,
		268369920, 0, 0, 0, 0, 0, 1056964608, 0, 0,
		0, 0, 0, 0, -1, 1, 0, 0, 0,
		0, -256, 32767, 0, 0, 0, 0, -65536, 1,
		0, 0, 0, 0, -16777216, 4095, 0, 0, 0,
		0, 0, -1, 32767, 0, 0, 0, 0, 3840,
		0, 0, 0, 0, 0, -65536, 67108863, 0, 0,
		0, 0, 16777216, 0, 0, 0, 0, 0, 0,
		2047, 0, 0, 0, 0, 0, 256, 0, 0,
		0, 0, 0, 65536, 0, 0, 0, 0, 0,
		-16777216, 2097151, 0, 0, 0, 0, 0, -1, 134217727,
		0, 0, 0, 0, 130816, 0, 0, 0, 0,
		0, 983040, 0, 0, 0, 0, 0, -16777216, -1,
		-1, -1, -1, 32767, 0, 524287, 0, 0, 0,
		0, 0, 256, 0, 0, 0, 0, 0, -65536,
		-1, -1, 33554431, 0, 0, -16777216, 127, 0, 0,
		0, 0, 0, 15, 0, 0, 0, 0, 0,
		32512, 0, 0, 0, 0, 0, 65536, 0, 0,
		0, 0, 0, -16777216, -1, 65535, 0, 0, 0,
		0, 8388607, 0, 0, 0, 0, 0, 65280, 0,
		0, 0, 0, 0, -65536, 1023, 0, 0, 0,
		0, -16777216, 511, 0, 0, 0, 0, 0, -1,
		7, 0, 0, 0, 0, 33554176, 0, 0, 0,
		0, 0, 16711680, 0, 0, 0, 0, 0, -16777216,
		-1, -1, -1, -1, 0, 0, 1048575, 0, 0,
		0, 0, 0, 3840, 0, 0, 0, 0, 0,
		2031616, 0, 0, 0, 0, 0, 16777216, 0, 0,
		0, 0, 0, 0, -1, -1, 511, 0, 0,
		0, -256, 33554431, 0, 0, 0, 0, -65536, 511,
		0, 0, 0, 0, 16777216, 0, 0, 0, 0,
		0, 0, 31, 0, 0, 0, 0, 0, 1792,
		0, 0, 0, 0, 0, 16711680, 0, 0, 0,
		0, 0, -16777216, -1, 131071, 0, 0, 0, 0,
		-1, -1, 7, 0, 0, 0, 130816, 0, 0,
		0, 0, 0, -65536, 16777215, 0, 0, 0, 0,
		-16777216, 1023, 0, 0, 0, 0, 0, 127, 0,
		0, 0, 0, 0, 256, 0, 0, 0, 0,
		0, -65536, 16777215, 0, 0, 0, 0, 16777216, 0,
		0, 0, 0, 0, 0, 1023, 0, 0, 0,
		0, 0, 256, 0, 0, 0, 0, 0, 65536,
		0, 0, 0, 0, 0, -16777216, 268435455, 0, 0,
		0, 0, 0, -1, -1, 0, 0, 0, 0,
		268435200, 0, 0, 0, 0, 0, -65536, 262143, 0,
		0, 0, 0, 16777216, 0, 0, 0, 0, 0,
		0, 1073741823, 0, 0, 0, 0, 0, -256, 16777215,
		0, 0, 0, 0, -65536, -1, -1, -1, 255,
		0, -16777216, 65535, 0, 0, 0, 0, 0, 31,
		0, 0, 0, 0, 0, 768, 0, 0, 0,
		0, 0, 67043328, 0, 0, 0, 0, 0, -16777216,
		65535, 0, 0, 0, 0, 0, 8191, 0, 0,
		0, 0, 0, -256, 1023, 0, 0, 0, 0,
		268369920, 0, 0, 0, 0, 0, -16777216, 2047, 0,
		0, 0, 0, 0, 63, 0, 0, 0, 0,
		0, 2147483392, 0, 0, 0, 0, 0, -65536, 63,
		0, 0, 0, 0, -16777216, 67108863, 0, 0, 0,
		0, 0, 1, 0, 0, 0, 0, 0, 7936,
		0, 0, 0, 0, 0, -65536, 4095, 0, 0,
		0, 0, -16777216, 32767, 0, 0, 0, 0, 0,
		4095, 0, 0, 0, 0, 0, -256, -1, -1,
		-1, -1, 15, -65536, 3, 0, 0, 0, 0,
		-16777216, 63, 0, 0, 0, 0, 0, -1, -1,
		3, 0, 0, 0, -256, 3, 0, 0, 0,
		0, -65536, -1, -1, 7, 0, 0, -16777216, 16383,
		0, 0, 0, 0, 0, 131071, 0, 0, 0,
		0, 0, 256, 0, 0, 0, 0, 0, 983040,
		0, 0, 0, 0, 0, 50331648, 0, 0, 0,
		0, 0, 0, 63, 0, 0, 0, 0, 0,
		256, 0, 0, 0, 0, 0, 4128768, 0, 0,
		0, 0, 0, -16777216, 7, 0, 0, 0, 0,
		0, 1, 0, 0, 0, 0, 0, 768, 0,
		0, 0, 0, 0, 458752, 0, 0, 0, 0,
		0, 16777216, 0, 0, 0, 0, 0, 0, -1,
		65535, 0, 0, 0, 0, -256, -1, -1, 1,
		0, 0, -65536, -1, -1, 33554431, 0, 0, 251658240,
		0, 0, 0, 0, 0, 0, -1, -1, 8191,
		0, 0, 0, -256, -1, -1, 3, 0, 0,
		-65536, -1, 1048575, 0, 0, 0, -16777216, -1, -1,
		3, 0, 0, 0, 65535, 0, 0, 0, 0,
		0, 32512, 0, 0, 0, 0, 0, -65536, 65535,
		0, 0, 0, 0, -16777216, -1, -1, 15, 0,
		0, 0, -1, 511, 0, 0, 0, 0, -256,
		-1, -1, 1, 0, 0, -65536, -1, -1, -1,
		4194303, 0, -16777216, -1, -1, 4095, 0, 0, 0,
		1, 0, 0, 0, 0, 0, 16128, 0, 0,
		0, 0, 0, 196608, 0, 0, 0, 0, 0,
		520093696, 0, 0, 0, 0, 0, 0, -1, 536870911,
		0, 0, 0, 0, -256, 4095, 0, 0, 0,
		0, -65536, 1073741823, 0, 0, 0, 0, -16777216, -1,
		-1, 8388607, 0, 0, 0, -1, -1, 262143, 0,
		0, 0, -256, -1, 262143, 0, 0, 0, -65536,
		-1, 8191, 0, 0, 0, -16777216, cellmax, 0, 0,
		0, 0, 0, -1, -1, 255, 0, 0, 0,
		-256, 2097151, 0, 0, 0, 0, -65536, -1, 127,
		0, 0, 0, -16777216, -1, -1, 127, 0, 0,
		0, 16777215, 0, 0, 0, 0, 0, 4194048, 0,
		0, 0, 0, 0, -65536, -1, 1048575, 0, 0,
		0, -16777216, 255, 0, 0, 0, 0, 0, 1,
		0, 0, 0, 0, 0, -256, 32767, 0, 0,
		0, 0, 33488896, 0, 0, 0, 0, 0, 16777216,
		0, 0, 0, 0, 0, 0, 2097151, 0, 0,
		0, 0, 0, -256, 524287, 0, 0, 0, 0,
		-65536, -1, 33554431, 0, 0, 0, -16777216, 33554431, 0,
		0, 0, 0, 0, 31, 0, 0, 0, 0,
		0, 256, 0, 0, 0, 0, 0, 268369920, 0,
		0, 0, 0, 0, -16777216, 1, 0, 0, 0,
		0, 0, 33554431, 0, 0, 0, 0, 0, 768,
		0, 0, 0, 0, 0, 983040, 0, 0, 0,
		0, 0, 50331648, 0, 0, 0, 0, 0, 0,
		127, 0, 0, 0, 0, 0, 65280, 0, 0,
		0, 0, 0, -65536, -1, 131071, 0, 0, 0,
		-16777216, -1, -1, -1, 3, 0, 0, -1, -1,
		-1, 4095, 0, 0, -256, 16777215, 0, 0, 0,
		0, -65536, 536870911, 0, 0, 0, 0, -16777216, 16777215,
		0, 0, 0, 0, 0, 2097151, 0, 0, 0,
		0, 0, 1048320, 0, 0, 0, 0, 0, -65536,
		-1, 255, 0, 0, 0, 16777216
	};
	return ((soundid >= 0) && ((soundid / 32) < sizeof (audiodat)) && (audiodat[soundid / 32] & (1 << (soundid % 32))));
}
I couldn't make it more neat, so i only split the array after every 9th. Feel free to give it a neat padding!

EDIT: I just remembered they said to use hexadecimal, so it looks clean, here is it (it is 11192 characters larger):
Code:
stock IsValidSound(soundid)
{
	static const audiodat[] =
	{
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0x0000007F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFFFFFF00, 0x0000003F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000FFFFF, 0xFF000000, 0x0000007F, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x0000001F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x0001FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3FFF0000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x0003FFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000300, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000F00, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1F000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000FF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x007FFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x007F0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x01FFFFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x000F0000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3F000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000F00,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00070000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x07FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFFFFFFFF, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3FFFFF00, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x0003FFFF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0x007FFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x1FFF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000007, 0x00000000, 0xFFFFFFFF, 0x000001FF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFFFFFF00, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00030000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x00000FFF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00001FFF, 0x00000000, 0x00000000, 0x00000000,
		0xFFFFFF00, 0xFFFFFFFF, 0xFFFFFFFF, 0x07FFFFFF, 0x00000000, 0x00000000, 0xFFFF0000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x0000007F, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x000003FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF,
		0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x0001FFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFF000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0xFF000000,
		0xFFFFFFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x00FFFFFF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000300, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x0FFF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3F000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFFFF00, 0x00007FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x00000001,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x00000FFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFFFFFFFF, 0x00007FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000F00,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x03FFFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x000007FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFF000000, 0x001FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x07FFFFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0001FF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x000F0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00007FFF, 0x00000000, 0x0007FFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000,
		0xFFFFFFFF, 0xFFFFFFFF, 0x01FFFFFF, 0x00000000, 0x00000000, 0xFF000000, 0x0000007F, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x0000000F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00007F00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x007FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FF00, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x000003FF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFF000000, 0x000001FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF,
		0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01FFFF00, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00FF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000,
		0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x000FFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000F00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x001F0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x000001FF, 0x00000000, 0x00000000,
		0x00000000, 0xFFFFFF00, 0x01FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x000001FF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x0000001F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000700,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00FF0000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0x0001FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFFFFFFFF, 0xFFFFFFFF, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x0001FF00, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x00FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFF000000, 0x000003FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000007F, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFF0000, 0x00FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000003FF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x0FFFFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x0FFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x0003FFFF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x3FFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x00FFFFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF,
		0x00000000, 0xFF000000, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001F,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000300, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x03FF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000,
		0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001FFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x000003FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x0FFF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x000007FF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000003F, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x7FFFFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x0000003F,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x03FFFFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001F00,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x00000FFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0xFF000000, 0x00007FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F, 0xFFFF0000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFF000000, 0x0000003F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
		0x00000003, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000007, 0x00000000, 0x00000000, 0xFF000000, 0x00003FFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0001FFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000F0000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x0000003F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x003F0000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000300, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00070000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF,
		0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000001,
		0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0x01FFFFFF, 0x00000000, 0x00000000, 0x0F000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00001FFF,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000003, 0x00000000, 0x00000000,
		0xFFFF0000, 0xFFFFFFFF, 0x000FFFFF, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF,
		0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00007F00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0x0000FFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F, 0x00000000,
		0x00000000, 0x00000000, 0xFFFFFFFF, 0x000001FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00,
		0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, 0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
		0x003FFFFF, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000FFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00003F00, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00030000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x1F000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x1FFFFFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x00000FFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFF0000, 0x3FFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF,
		0xFFFFFFFF, 0x007FFFFF, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x0003FFFF, 0x00000000,
		0x00000000, 0x00000000, 0xFFFFFF00, 0xFFFFFFFF, 0x0003FFFF, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000,
		0xFFFFFFFF, 0x00001FFF, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x7FFFFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF, 0x00000000, 0x00000000, 0x00000000,
		0xFFFFFF00, 0x001FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0x0000007F,
		0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000007F, 0x00000000, 0x00000000,
		0x00000000, 0x00FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x003FFF00, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0x000FFFFF, 0x00000000, 0x00000000,
		0x00000000, 0xFF000000, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x00007FFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x01FF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x001FFFFF, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFFFF00, 0x0007FFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0xFFFF0000, 0xFFFFFFFF, 0x01FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x01FFFFFF, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001F, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0FFF0000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x01FFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000300,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000F0000, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x03000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
		0x0000007F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000FF00, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0x0001FFFF, 0x00000000, 0x00000000, 0x00000000,
		0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000003, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
		0xFFFFFFFF, 0x00000FFF, 0x00000000, 0x00000000, 0xFFFFFF00, 0x00FFFFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0xFFFF0000, 0x1FFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, 0x00FFFFFF,
		0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x001FFFFF, 0x00000000, 0x00000000, 0x00000000,
		0x00000000, 0x00000000, 0x000FFF00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFF0000,
		0xFFFFFFFF, 0x000000FF, 0x00000000, 0x00000000, 0x00000000, 0x01000000
	};
	return ((soundid >= 0) && ((soundid / 32) < sizeof (audiodat)) && (audiodat[soundid / 32] & (1 << (soundid % 32))));
}
Just look at the usage time:
Code:
IsValidSoundSlow time: 225 ms
IsValidSound time: 11 ms
There is no any special benchmark code, i only used code to loop from 0 to 45400 to compare the times.

Note about "dat": you can store the audiodat[] array with fblockwrite and load it with fblockread if you want it to be more flexible, the file is attached below...
Reply

pawn Code:
Color_GetBrightness(color)
{
    new r = ((color >> 24) & 0xFF) * 1000 / 255,
        g = ((color >> 16) & 0xFF) * 1000 / 255,
        b = ((color >> 8) & 0xFF) * 1000 / 255,
       
        max_value = max(max(r, g), b),
        min_value = min(min(r, g), b);
   
    return (max_value + min_value) / 20;
}
or
pawn Code:
RGB_GetBrightness(red_value, green_value, blue_value)
{
    new r = red_value * 1000 / 255,
        g = green_value * 1000 / 255,
        b = blue_value * 1000 / 255,

        max_value = max(max(r, g), b),
        min_value = min(min(r, g), b);
   
    return (max_value + min_value) / 20;
}
returns percentage (0-100) of brightness (ignoring alpha value, only used for client messages).

Example use:
pawn Code:
CMD:color(playerid, params[])
{
    new R, G, B;

    if (sscanf(params, "ddd", R, G, B)) return SendClientMessage(playerid, -1, "USAGE: /color <Red: 0-255> <Green: 0-255> <Blue: 0-255>");
    if (RGB_GetBrightness(R, G, B) <= 10) return SendClientMessage(playerid, -1, "ERROR: Choose a lighter color.");
 
    // create color and set for player
    return 1;
}
Reply

Quote:
Originally Posted by Calisthenics
View Post
//code
With this code can i set color darker or lighter?
Reply

Quote:
Originally Posted by Symon
View Post
With this code can i set color darker or lighter?
There are different implementations, I like this one: https://stackoverflow.com/a/13532993

pawn Code:
Color_ChangeShadow(color, percent)
{
    new r = clamp(((color >> 24) & 0xFF) * (100 + percent) / 100, 0, 255),
        g = clamp(((color >> 16) & 0xFF) * (100 + percent) / 100, 0, 255),
        b = clamp(((color >> 8) & 0xFF) * (100 + percent) / 100, 0, 255),
        a = color & 0xFF;
       
    return (r << 24) | (g << 16) | (b << 8) | a;
}
Returns the new color.

percent > 0 (lighter)
percent = 0 (same)
percent < 0 (darker)
Reply

So can i use it directly with SetPlayerColor?
Reply

Another useful vehicle function in addition to the previous post

DoesVehicleHaveTurret

pawn Code:
DoesVehicleHaveTurret(modelid)
{
    switch(modelid)
    {
        case 407, 432, 564, 601: return 1;
    }
    return 0;
}
Reply

CreateParticle and CreateParticleForPlayer functions:
pawn Code:
stock CreateParticle(type, Float:X, Float:Y, Float:Z, Float:DrawDistance = 0.0, time = 0)
{
    new particleid = CreateObject(type, X, Y, Z, 0.0, 0.0, 0.0, DrawDistance);
    if(time > 0) SetTimerEx("DestroyParticle", time, 0, "i", particleid);
    return particleid;
}

forward DestroyParticle(particleid);
public DestroyParticle(particleid) return DestroyObject(particleid);

stock CreateParticleForPlayer(playerid, type, Float:X, Float:Y, Float:Z, Float:DrawDistance = 0.0, time = 0)
{
    new particleid = CreatePlayerObject(playerid, type, X, Y, Z, 0.0, 0.0, 0.0, DrawDistance);
    if(time > 0) SetTimerEx("DestroyParticleForPlayer", time, 0, "ii", playerid, particleid);
    return particleid;
}

forward DestroyParticleForPlayer(playerid, particleid);
public DestroyParticleForPlayer(playerid, particleid) return DestroyPlayerObject(playerid, particleid);
List of particles (to be used as "type" parameter):
pawn Code:
#define WATERSPLASH             18720
#define FIRE_BIKE               18689
#define FLAMETHROWERP           18694
#define WATER_HYDRANT           18740
#define EXHALE                  18677
#define BLOODPOOL1              19836
#define SMOKE30LIT              18725
#define SHOOTLIGHT              18724
#define RIOT_SMOKE              18723
#define PUKE                    18722
#define PRT_WHEELDIRT           18721
#define PRT_WAKE                18719
#define SMOKE50LIT              18727
#define PRT_SPARK_2             18718
#define PRT_SPARK               18717
#define PRT_SMOKE_EXPAND        18716
#define PRT_SMOKE_HUGE          18715
#define PRT_SAND                18714
#define PRT_SAND2               18713
#define PRT_GUNSHELL            18712
#define PRT_GLASS               18711
#define SMOKE30M                18726
#define SPRAYCANP               18729
#define SMOKE_FLARE             18728
#define WATER_FOUNTAIN          18739
#define WATERFALL_END           18747
#define WATER_SWIM              18746
#define WATER_SPLSH_SML         18745
#define WATER_SPLASH_BIG        18744
#define WATER_SPLASH            18743
#define WATER_SPEED             18742
#define WATER_RIPPLES           18741
#define WATER_FNT_TME           18738
#define PRT_CARDEBRIS           18709
#define WALLBUST                18737
#define VENT                    18736
#define VENT2                   18735
#define TREE_HIT_PALM           18734
#define TREE_HIT_FIR            18733
#define TEARGASAD               18732
#define TEARGAS99               18731
#define TANK_FIRE               18730
#define PRT_COLLISIONSMOKE      18710
#define PRT_BLOOD               18706
#define PRT_BUBBLE              18708
#define COKE_PUFF               18675
#define EXPLOSION_MEDIUM        18683
#define EXPLOSION_LARGE         18682
#define EXPLOSION_FUEL_CAR      18681
#define EXPLOSION_DOOR          18680
#define EXPLOSION_CRATE         18679
#define EXPLOSION_BARREL        18678
#define COKE_TRAIL              18676
#define CLOUDFAST               18674
#define EXPLOSION_SMALL         18685
#define CIGARETTE_SMOKE         18673
#define CEMENTP                 18672
#define CARWASHSPRAY            18671
#define CAMFLASH                18670
#define BOAT_PROP               18669
#define BLOOD_HELI              18668
#define EXPLOSION_MOLOTOV       18684
#define EXPLOSION_TINY          18686
#define PRT_BOATSPLASH          18707
#define JETPACKP                18699
#define PETROLCAN               18705
#define OVERHEAT_CAR_ELEC       18704
#define OVERHEAT_CAR            18703
#define NITROP                  18702
#define MOLOTOV_FLAME           18701
#define JETTHRUST               18700
#define INSECTS                 18698
#define EXTINGUISHER            18687
#define HELI_DUST               18697
#define GUNSMOKE                18696
#define GUNFLASH                18695
#define FLAME99                 18693
#define FIRE_MED                18692
#define FIRE_LARGE              18691
#define FIRE_CAR                18690
#define FIRE                    18688
#define WS_FACTORYSMOKE         18748
Example:
pawn Code:
CreateParticle(PRT_SMOKE_HUGE, 1958.3783, 1343.1572, 15.3746, 0.0, 1500); //Create huge smoke particle for 1500 ms
Reply

Couldn't find a function for this so figured I created one: similar_hexes.
It compares two hex colors (in 0xRRGGBB format, not any other format such as 0xRRGGBBAA or 0xAARRGGBB) and decides if they are similar colors or not:

pawn Code:
similar_hexes(hex_a, hex_b, difference = 150)
{
    new R[2], G[2], B[2], diff[3];
    R[0] = (hex_a >>> 16) & 0xFF;
    G[0] = (hex_a >>> 8) & 0xFF;
    B[0] = (hex_a) & 0xFF;
    R[1] = (hex_b >>> 16) & 0xFF;
    G[1] = (hex_b >>> 8) & 0xFF;
    B[1] = (hex_b) & 0xFF;

    diff[0] = floatround(difference * 0.14);
    diff[1] = floatround(difference * 0.2);
    diff[2] = floatround(difference * 0.48);

    return //returns 1(true) if they are similar and 0(false) if they are not.
    (
        (R[0] - diff[0] <= R[1] && R[1] <= R[0] + diff[0]) &&
        (G[0] - diff[1] <= G[1] && G[1] <= G[0] + diff[1]) &&
        (B[0] - diff[2] <= B[1] && B[1] <= B[0] + diff[2])
    );
}
It is not always totally accurate (eg. 5566FF and 6655CC don't look alot like each other but it is returned as "similar" anyway -just like eg. E7E7E7 and F0F0B0) but I got the best results with most tests so far with "difference = 150".
Had to tweak differences for R,G and B a bit because otherwise it would return "not similar" if the colors were actually similar (most being 'faulty' in the BB value) - and the R value would often return "similar" while they weren't.

Feel free to improve it.

If there's a better function around I'd like to know aswell


Here's a small (and very poorly scripted) testscript (.html) to test it if you'd like; https://pastebin.com/mhp0pa5g
Insert RRGGBB color (without 0x) in the two boxes and press "Check".
It will show both colors you entered and will print "YES" if they are similar and "NO" if they are not.
Reply

A poorly coded number checker, what does it do?
It gets me the number written in a string firstly. like Stringab12cd456gh returns 12 !
i wanted it in some process so did this shit:

like:
PHP Code:
printf("ANDEBUG: %i"GetNumberFromString("ezpz12r3")); 
prints 12.

PHP Code:
GetNumberFromString(string[])
{
    new 
str[10], cnt = -1tmps[2];
    for(new 
0len strlen(string); leni++)
    {
        if(
isNumber(stringi) && cnt == -1)
        {
            
format(tmps2string[i]);
            
strcat(strtmps);
            
cnt i;
        }
        if(
isNumber(stringi) && cnt == i-1)
        {
            
format(tmps2string[i]);
            
strcat(strtmps);
            
cnt i;
        }
    }
    new 
intt;
    
intt strval(str);
    return 
intt;
}
isNumber(c[], index)
{
    switch(
c[index])
    {
        case 
'0' .. '9': return true;
        default: return 
false;
    }
    return 
false;

Reply

@Nexius I like that you used global objects for temp objects.
Reply

Quote:
Originally Posted by Pottus
View Post
@Nexius I like that you used global objects for temp objects.
You can easily use streamer's dynamic objects as well, but I prefer not to tow dependencies in any code I see which might not even need them for some people in their scripts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)