rendered paste body/*
native IsValidSound(soundid);
native IsABike(vehicleid);
native IsABoat(vehicleid);
native IsAHeli(vehicleid);
native IsAPlane(vehicleid);
native IsATrain(vehicleid);
native IsATruck(vehicleid);
native IsATrailer(vehicleid);
native IsAnUnquine(vehicleid);
native GetVehicleName(vehicleid);
native GetVehicleRealName(vehicleid);
native IsVehicleUpsideDown(vehicleid);
native FindVehicleName(modelid,name[],bool:real);
native strreplace(string[], const find[], const replace[], bool:ignorecase=false, count=cellmax, maxlength=sizeof(string));
native strcopy(dest[], source[], len=sizeof(source)) strmid(dest, source, 0, len, len);
native ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5);
native ReturnUser(text[], playerid = INVALID_PLAYER_ID);
native strtok(string[],&idx,seperator = ' ');
native ReturnPlayer(text[]);
native RollTheDice(playerid, diceamount, MIN_AMOUNT = 5000, MAX_AMOUNT = 35000)
native rand(minnum = cellmin,maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
*/
//--------------------------------------------------------------------------------------------------------------------------------------------//
#define GetTime gettime
#define GetDate getdate
#define ms
#define secs *1000 ms
#define mins *60 secs
/* Usage of above code
SetTimer("MyFunc", 5 mins, 1);
SetTimer("MyFunc", 7 secs, 1);
SetTimer("MyFunc", 28 ms, 1);
Looks kinda cool, huh ?
*/
#define isNull isnull
#define IsNull isNull
#define SetVehicleInterior LinkVehicleToInterior
#define loop(%1,%2) for( new %1; %1 < %2; %1++ )
#define Loop loop
#define LOOP Loop
#define Do do
#define DO Do
#define While while
#define WHILE While
#define DoWhile while
//#define Log(%0,%1) do{new File:logfile; logfile = fopen(%0, io_append); fwrite(logfile, %1); fclose(logfile);}while(FALSE)
#define strcpy(%0,%1,%2) \
strcat((%0[0] = '\0', %0), %1, %2)
stock RepairPlayerVehicle(playerid)
{
new rCar = GetPlayerVehicleID(playerid);
SetVehicleHealth(rCar, 1000.0); RepairVehicle(rCar);
return printf("Player %d repaired his vehicle in a repair zone",playerid);
}
enum e_THING
{
Player,
Vehicle,
StaticObject,
DynamicObject
}
stock IsThingInArea(Thing_ID, Float:MinX, Float:MaxX, Float:MinY, Float:MaxY, e_THING:Thing=Vehicle)
{
new Float:Thing_x, Float:Thing_y, Float:Thing_z;
switch(Thing)
{
case DynamicObject: GetDynamicObjectPos(Thing_ID, Thing_x, Thing_y, Thing_z);
case StaticObject: GetObjectPos(Thing_ID, Thing_x, Thing_y, Thing_z);
case Vehicle: GetVehiclePos(Thing_ID, Thing_x, Thing_y, Thing_z);
case Player: GetPlayerPos(Thing_ID, Thing_x, Thing_y, Thing_z);
}
if(Thing_x > MinX && Thing_x < MaxX && Thing_y > MinY && Thing_y < MaxY) return 1;
return 0;
}
stock IsValidPayNSprayVehicle(vehicleid)
{
new InvalidVehicles[13] =
{
407, //firetruck
416, //ambulance
427, //enforcer
432, //rhino
433, //barracks
490, //fbi rancher
528, //fbi truck
523, //hpv1000
596, //police car lspd
597, //police car sfpd
598, //police car lvpd
599, //police ranger
601 //s.w.a.t. car
};
for(new i=0; i<13; i++)
{
if(GetVehicleModel(vehicleid) == InvalidVehicles[i])
{
return 0;
}
}
return 1;
}
stock GetVehicleColorName(color)
{
new clr[32];
switch(color)
{
case 0: clr ="Black";
case 1: clr ="White";
case 2: clr ="Blue";
case 3: clr ="Red";
case 4: clr ="Grey-Green";
case 5: clr ="Purple";
case 6: clr ="Yellow";
case 7: clr ="Blue";
case 8: clr ="Silver";
case 9: clr ="Dark sGrey";
case 10: clr ="Midnight Blue";
case 11: clr ="Dark Grey";
case 12: clr ="Teal";
case 13: clr ="Dark Grey";
case 14: clr ="Light Grey";
case 15: clr ="Silver";
case 16: clr ="Dark Green";
case 17: clr ="Dark Red";
case 18: clr ="Dark Red";
case 19: clr ="Grey";
case 20: clr ="Royal Blue";
case 21: clr ="Rich Maroon";
case 22: clr ="Rich Maroon";
case 23: clr ="Grey";
case 24: clr ="Dark Grey";
case 25: clr ="Dark Grey";
case 26: clr ="Light Grey";
case 27: clr ="Grey";
case 28: clr ="Midnight Blue";
case 29: clr ="Light Grey";
case 30: clr ="Dark Maroon";
case 31: clr ="Red";
case 32: clr ="Baby Blue";
case 33: clr ="Grey";
case 34: clr ="Grey";
case 35: clr ="Dark Grey";
case 36: clr ="Dark Grey";
case 37: clr ="";
case 38: clr ="Tea Green";
case 39: clr ="Steel blue";
case 40: clr ="Black";
case 41: clr ="Light Brown";
case 42: clr ="Bright Maroon";
case 43: clr ="Maroon";
case 44: clr ="Myrtle Green";
case 45: clr ="Maroon";
case 46: clr ="Olive Green";
case 47: clr ="Olive";
case 48: clr ="Khaki Brown";
case 49: clr ="Light Grey";
case 50: clr ="Silver Grey";
case 51: clr ="Dark Green";
case 52: clr ="Dark Teal";
case 53: clr ="Navy Blue";
case 54: clr ="Navy Blue";
case 55: clr ="Brown";
case 56: clr ="Light Grey";
case 57: clr ="Beige";
case 58: clr ="Maroon";
case 59: clr ="Grey-Blue";
case 60: clr ="Grey";
case 61: clr ="Old Gold";
case 62: clr ="Maroon";
case 63: clr ="Grey";
case 64: clr ="Grey";
case 65: clr ="Old Gold";
case 66: clr ="Dark Brown";
case 67: clr ="Light Blue";
case 68: clr ="Light Khaki";
case 69: clr ="Light Pink";
case 70: clr ="Bright Maroon";
case 71: clr ="Light Blue";
case 72: clr ="Grey";
case 73: clr ="Tea Green";
case 74: clr ="Dark Maroon";
case 75: clr ="Dark Blue";
case 76: clr ="Light Brown";
case 77: clr ="Ecru Brown";
case 78: clr ="Maroon";
case 79: clr ="Royal Blue";
case 80: clr ="Rich Maroon";
case 81: clr ="Light Brown";
case 82: clr ="Bright Maroon";
case 83: clr ="Dark Teal Green";
case 84: clr ="Brown";
case 85: clr ="Rich Maroon";
case 86: clr ="Green";
case 87: clr ="Blue ";
case 88: clr ="Maroon";
case 89: clr ="Beige";
case 90: clr ="Grey";
case 91: clr ="Dark Blue";
case 92: clr ="Grey";
case 93: clr ="Sky Blue";
case 94: clr ="Blue";
case 95: clr ="Navy Blue";
case 96: clr ="Silver";
case 97: clr ="Light Blue";
case 98: clr ="Grey";
case 99: clr ="Light Brown ";
case 100: clr ="Blue";
case 101: clr ="Dark Blue";
case 102: clr ="Light Brown";
case 103: clr ="Blue";
case 104: clr ="Brown";
case 105: clr ="Dark Grey";
case 106: clr ="Blue";
case 107: clr ="Light Brown";
case 108: clr ="Yale Blue";
case 109: clr ="Dark Grey";
case 110: clr ="Brown";
case 111: clr ="Light Grey";
case 112: clr ="Blue";
case 113: clr ="Brown";
case 114: clr ="Dark Grey";
case 115: clr ="Dark Red";
case 116: clr ="Navy Blue";
case 117: clr ="Dark Maroon";
case 118: clr ="Light Blue";
case 119: clr ="Brown";
case 120: clr ="Light Brown";
case 121: clr ="Dark Maroon";
case 122: clr ="Grey";
case 123: clr ="Brown";
case 124: clr ="Rich Maroon";
case 125: clr ="Dark Blue";
case 126: clr ="Pink";
}
return clr;
}
#define IsAHeli IsAHelicopter
#define randarg(...) getarg(random(numargs()))
#define ConvertSpeedToKMH(%1) ((%1)/1500)
#define ConvertSpeedToMPH(%1) ((%1)/1000)
#define IsValidVehicleModel(%1) (400 <= %1 && %1 <= 611)
stock maxex(...)
{
new
i = numargs(),
h = -1,
s = cellmin;
// Loop through all the numbers
while (i--)
{
// See if this one is bigger than the old max
if (getarg(i) >= s)
{
// Save the details
h = i;
s = getarg(i);
}
}
// Return the largest number
// return s;
// OR return the position of the largest number
// return h;
// Uncomment ONE of the above return lines depending on your needs
}
stock maxarr(arr[], size = sizeof (arr))
{
new
h = -1,
s = cellmin;
// Loop through all the numbers
while (size--)
{
// See if this one is bigger than the old max
if (arr[size] >= s)
{
// Save the details
h = size;
s = arr[size];
}
}
// Return the largest number
// return s;
// OR return the position of the largest number
// return h;
// Uncomment ONE of the above return lines depending on your needs
}
stock minex(...)
{
new
i = numargs(),
h = -1,
s = cellmax;
// Loop through all the numbers
while (i--)
{
// See if this one is smaller than the old min
if (getarg(i) <= s)
{
// Save the details
h = i;
s = getarg(i);
}
}
// Return the smallest number
// return s;
// OR return the position of the smallest number
// return h;
// Uncomment ONE of the above return lines depending on your needs
}
stock minarr(arr[], size = sizeof (arr))
{
new
h = -1,
s = cellmax;
// Loop through all the numbers
while (size--)
{
// See if this one is smaller than the old min
if (arr[size] <= s)
{
// Save the details
h = size;
s = arr[size];
}
}
// Return the smallest number
// return s;
// OR return the position of the smallest number
// return h;
// Uncomment ONE of the above return lines depending on your needs
}
stock GetWheelIDFromName(name[])
{
if(!strcmp("Shadow", name)) return 1073;
if(!strcmp("Mega", name)) return 1074;
if(!strcmp("Rimshine", name)) return 1075;
if(!strcmp("Wires", name)) return 1076;
if(!strcmp("Classic", name)) return 1077;
if(!strcmp("Twist", name)) return 1078;
if(!strcmp("Cutter", name)) return 1079;
if(!strcmp("Switch", name)) return 1080;
if(!strcmp("Grove", name)) return 1081;
if(!strcmp("Import", name)) return 1082;
if(!strcmp("Dollar", name)) return 1083;
if(!strcmp("Atomic", name)) return 1084;
if(!strcmp("Trance", name)) return 1085;
return -1; // If the name given doesn't math any wheel name we returm '-1'
}
stock IsValidSound(soundid)
{
new Sounds[] = { 1002, 1009, 1027, 1035, 1036, 1039, 1052, 1053,
1054, 1055, 1056, 1057, 1058, 1062, 1063, 1068,
1069, 1076, 1077, 1083, 1084, 1085, 1097, 1098,
1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137,
1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145,
1146, 1147, 1148, 1149, 1150, 1153, 1154, 1163,
1165, 1166, 1169, 1183, 1184, 1185, 1186, 1187,
1188 };
for(new i = 0; i < sizeof(Sounds); i++)
{
if(soundid == i) return 1;
}
return 0;
}
stock IsVehicleUpsideDown(vehicleid)
{
new Float:quat_w,Float:quat_x,Float:quat_y,Float:quat_z;
GetVehicleRotationQuat(vehicleid,quat_w,quat_x,quat_y,quat_z);
new Float:y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
return (y > 90 || y < -90);
}
/*
You win if: The dealer rolls (3 & 4) and you roll (4 & 4). As long as the amount of both the dices is higher than the dealer's one you will win
but...
You double win if: The dealer rolls (5 & 6) and you roll (2 & 2). Here the amount doesn't matter because you got 2x the same dice (automaticly win in this case and 2x your bet).
*/
stock RollTheDice(playerid, diceamount, MIN_AMOUNT = 5000, MAX_AMOUNT = 35000)
{
new dice[4], string[128];
if(diceamount < MIN_AMOUNT || diceamount > MAX_AMOUNT)
{
format(string, sizeof(string), "Invalid amount. The gamble amount must be between $%d and $%d!", MIN_AMOUNT, MAX_AMOUNT);
return SendClientMessage(playerid, 0xB60000FF, string);
}
if(diceamount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xB60000FF, "You don't have that much money!");
else
{
dice[0] = RandomEx(1, 6); dice[1] = RandomEx(1, 6);
dice[2] = RandomEx(1, 6); dice[3] = RandomEx(1, 6);
if((dice[0] + dice[1]) > (dice[2] + dice[3]) && (dice[2] + dice[3] * 2) != (dice[0] + dice[1]))
{
if((dice[0] == dice[1]) && (dice[0] + dice[1]) > (dice[2] + dice[3]))
{
GivePlayerMoney(playerid, (diceamount * 2));
format(string, sizeof(string), "Double win! You rolled %d and %d and the dealer rolled %d and %d.", dice[0], dice[1], dice[2], dice[3]);
}
else
{
GivePlayerMoney(playerid, diceamount);
format(string, sizeof(string), "You win! You rolled %d and %d and the dealer rolled %d and %d.", dice[0], dice[1], dice[2], dice[3]);
}
}
if((dice[0] + dice[1]) < (dice[2] + dice[3]))
{
GivePlayerMoney(playerid, -diceamount);
format(string, sizeof(string), "You lose! You rolled %d and %d and the dealer rolled %d and %d. Better luck next time!", dice[0], dice[1], dice[2], dice[3]);
}
if((dice[0] + dice[1]) == (dice[2] + dice[3]))
{
format(string, sizeof(string), "There was a tie! You rolled %d and %d and the dealer rolled %d and %d.", dice[0], dice[1], dice[2], dice[3]);
}
SendClientMessage(playerid, 0x00FFFFFF, string);
}
return 1;
}
new __string[128];
#define SendFormattedMSG(%0,%1,%2) \
format(__string, sizeof(__string), %2); \
SendClientMessage((%0), (%1), __string)
#define SendFormattedMSG_ToAll(%0,%1) \
format(__string, sizeof(__string), %1); \
SendClientMessageToAll((%0), __string)
#define SendFormatMessage_ToAll SendFormattedMSG_ToAll
#define SendFormattedMessage_ToAll SFM_ToAll
#define SendFormatMessage SendFormattedMSG
#define SCM_ToAll SendClientMessageToAll
#define SFM_ToAll SendFormattedMSG_ToAll
#define SendFormattedMessage SFM
#define GetPlayerIP GetPlayerIp
#define SCM SendClientMessage
#define SFM SendFormattedMSG
new VehicleNames[212][] = {
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance",
"Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife",
"Trailer","Previon","Coach","Cabbie","Stallion","Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder","Reefer",
"Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad",
"Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR 350","Walton","Regina","Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher",
"Virgo","Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa","RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher",
"Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000",
"Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent","Bullet",
"Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus","Jester","Sultan",
"Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley",
"Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B","Stair Trailer","Boxville","Farm Plow","Utility Trailer"
};
new RealVehicleNames[][] =
{
"Jeep Wagoneer","Mercury Cougar","Camaro with Scoop","Big Rig","Jeep Grand Wagoneer","BMW 7-Series","Dumptruck","SA Firetruck","Peterbuilt","Lincoln Towncar","Dodge Aries",
"Acura NSX '05","Chevy Biscayne","Ford Aerostar","Ford Box Van","Ferrari Testarosso","Ford Econoline","Emergency Helicopter","Chevrolet Astrovan","Cadillac Eldorado",
"Chevy Caprice","Lincoln Mark 7","Chevrolet S10","Chevy Ice Cream Truck","Volkswagen Beach Buggy","AH-64A","Chevrolet Caprice", "International SWAT Van","Securita Van",
"Dodge Viper","Preditor","Volvo Bus","M1A1 Abrams","Barracks","Ford Hot Rod","Trailer","Nissan Pulsar","Old Coach","Caprice Classic Cab","Ford Mustang Mach 1","Mercedes Van",
"RC Bandit","Cadillac Hearse","Packer/Stunt Helper","Chevy S-10 Monster Truck","Mercedes-Benz S-Class","Chris Craft Stinger","Bell 47G","Piaggio Vespa PX 200","Tram","Trailer",
"Ferrari F40", "Go-Fast Boat","Orca","Sea Ray 270 Sedan Bridge","Flatbed","1992 Ford F800","Golf Car","Ford Taurus Wagon","Honda Life '74","Cessna 150 With Floats","Honda CBR 600 '92",
"Piaggio Vespa PX 200 '86","Harley Davidson Soft Tail","RC Red Baron","RC Raider","Dodge Dart","Plymouth Belverdere","Yamaha DT 200 Dirt Bike","Bell 47G","Hummer H-1","Honda TRX250x '92",
"Coastguard Boat","Rescue Boat","Mercury '51","Chevy Chevelle","Curtiss P-40D Warhawk","Mazda RX-7","Chevy Farm Truck","Chevy Caprice Estate","Porsche 911","Schwinn BMX","Dodge Ramvan",
"Volkswagen Bus","Endeavour 42","Equitech M40 '85","Bulldozer","Bell 206L-4","Bell 206B-3","Ford Bronco","Chevrolet Suburban '92","Lincoln Mark 7","Dodge Diplomat","CMN Interceptor DV-15",
"Ford Mustang LX","Ford Bronco","Honda CRX","Bell 206L-4","Chevy Cargo Van","Ford Moving Van","Jeep Wrangler","RC Heli","Ford Mustang LX '86","Ford Mustang LX '86","Customised Glendale",
"Ford Bronco '80","Mitsubishi 3000 GT","Buick Roadmaster","GMC R.V.","Old Bike","Schwinn Mesa Mountain Hardtail","C-2 Greyhound","Grumman G-164 AgCat","Pitt's Special","Gas Tanker",
"International 9370 Truck","Lincoln Towncar","Chevy Monte Carlo","Chevrolet Monte Carlo","Bombardier Learjet 55","AV-8 Harrier Jump-Jet","Honda CBR 900 RR Fireblade","Honda NSR 500 '01",
"Kawasaki KZ1000-P21","Chevrolet Cement Truck","Tow Truck '91","Ford Thunderbird","Ford Escort","CSI/FBI Investigation Truck","Dodge Dynasty","Forklift '89","Old Tractor","Combine Harvester",
"Mercedes-Benz SL-Class","Lincoln Mark 5","Chevy CST '68","Chevrolet Caprice Droptop","1972 EMD SD40","Amtrak F40PH","Hovercraft","Mercedes Benz E120","Ford GT-40","Dodge Challenger '70",
"Dodge 100 Series","SA Firetruck","Ford Hotrod","Chevrolet Lumina","Oldsmobile Cutlass Ciera","Sikorsky CH-53","Dodge Roadrunner","Late 80's Honda Sedan","Mercury Grand Marquis",
"Chevy 2500","Douglas C-47","GMC Sierra","Jaguar XKE '66","Chevy S-10 Monster Truck","Chevy S-10 Monster Truck","Eagle Talon","Toyota Supra","Impreza 2.5RS '95","Honda Accord Wagon",
"Nissan R34 Skyline","Sikorsky UH-60 Black Hawk","RC Tiger","Honda Civic","Oldsmobile Cutlass","Chevy Impala","Half Life 2 Sand Rail","EMD SD40","Trailer","Go Kart","Ride-On Lawn Mower",
"Mercedes-Benz AK 4x4 '91","Elgin Pelican","Caddilac '54","Chevy Bel Air '57","Boeing 737","Flatbed","Range Rover","Rolls Royce","Honda VFR 400","Dodge Ramvan Newsvan",
"Baggage Tow Tractor HTAG-30/40","Trailer","Infinity J30 '92","Honda Goldwing GL1500 '04","Nissan 350Z/240SX","Hotdog Van","Volkswagen Golf","Trailer","Trailer","Lockheed C-5 Galaxy",
"Cessna 150","Unknown","CMN Interceptor DV-15","Chevy Caprice LA", "Chevy Caprice SF","Chevy Caprice LV","Chevy Blazer Desert","Chevrolet El Camino '68","S.W.A.T. Van",
"Dodge Stealth '91","Pontiac Trans AM", "Dodge Dart", "Dodge 100 Series", "Luggage Trailer","Luggage Trailer", "Stair Trailer", "Chevy Cargo Van","Farm Plow", "Chevy 2500 Trailer"
};
stock FindVehicleName(modelid,bool:real)
{
new vehname[32] = "unknown";
if(modelid >= 400) modelid-=400;
if(modelid < 212 && modelid > 0)
{
if(!real) format(vehname,sizeof(vehname),"%s",VehicleNames[modelid]);
else format(vehname,sizeof(vehname),"%s",RealVehicleNames[modelid]);
}
return vehname;
}
#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
stock ReplaceCharactersInString(string[], What, With)
{
new c, i = 0;
while((c = string[i]))
{
if (c == What) string[i] = With;
i++;
}
}
stock strreplace(string[], const find[], const replace[], bool:ignorecase=false, count=cellmax, maxlength=sizeof(string)) // The real one
{
if(isnull(find) || isnull(string)) return 0;
new matches;
for(new idx, flen = strlen(find), rlen = strlen(replace), pos = strfind(string, find, ignorecase); pos != -1 && idx < maxlength && matches < count; pos = strfind(string, find, ignorecase, idx))
{
strdel(string, pos, pos + flen);
if(rlen) strins(string, replace, pos, maxlength); // Crashy
idx = pos + rlen;
matches++;
}
return matches;
}
strcopy(dest[], source[], len=sizeof(source)) strmid(dest, source, 0, len, len);
#define rand(%1,%2) (random(%2 - %1 + 1) + %1)
stock IsVehicleEmpty(VehicleID)
{
foreach(Player, i)
{
if(IsPlayerInVehicle(i, VehicleID))
{
return 0;
}
}
return 1;
}
stock TotalVehicles()
{
new vid;
vid = CreateVehicle(411, 0, 0, 0, 0, -1, -1, 10);
DestroyVehicle(vid);
vid--;
return vid;
}
stock ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
//radi = 2.0; //Trigger Radius
foreach(Player, i)
{
GetPlayerPos(i, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, str);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, str);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, str);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, str);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, str);
}
}
return 1;
}
stock ReturnPlayer(text[])
{
new pos = 0, userid = INVALID_PLAYER_ID, count = 0, name[MAX_PLAYER_NAME],len = strlen(text[pos]);
foreach(Player, i)
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
// Exact match
if (len == strlen(name)) return i;
else // Partial match
{
count++;
userid = i;
}
}
}
if (count != 1) return INVALID_PLAYER_ID;
return userid; // INVALID_USER_ID for bad return
}
#define FLOAT_INFINITY (Float:0x7F800000)
#define FLOAT_NEG_INFINITY (Float:0xFF800000)
#define FLOAT_NAN (Float:0xFFFFFFFF)
#define IsNaN(%0) return !(%0 <= 0 || %0 > 0);
#define isnumeric isNumeric
stock isNumeric(const string[])
{
new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
if (
(string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
|| (string[i]=='-' && i!=0) // A '-' but not at first.
|| (string[i]=='+' && i!=0) // A '+' but not at first.
) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
return true;
}
#define IsNumeric isNumeric
stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
//if (playerid != INVALID_PLAYER_ID)
//{
// SendClientMessage(playerid, 0xFF0000AA, "User not connected");
//}
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
foreach(Player, i)
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(name)) // Exact match
{
return i; // Return the exact player on an exact match
// Otherwise if there are two players:
// Me and MeYou any time you entered Me it would find both
// And never be able to return just Me's id
}
else // Partial match
{
count++;
userid = i;
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_USER_ID for bad return
}
stock Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2)
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1,rx2),2)),floatsqroot(floatpower(floatsub(ry1,ry2),2))),floatsqroot(floatpower(floatsub(rz1,rz2),2)));
}
stock IsAPlane(vehicleid)
{ new model = GetVehicleModel(vehicleid);
if(model == 592 || model == 577 || model == 511 || model == 512 || model == 593 || model == 520 || model == 553 || model == 476 || model == 519 || model == 460 || model == 513)
{
return 1;
}
return 0;
}
stock IsABike(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 462 || model == 481 || model == 509 || model == 510 || model == 521 || model == 463 || model == 522 || model == 461 || model == 448 || model == 471 || model == 468 || model == 586)
{
return 1;
}
return 0;
}
stock IsATrailer(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 435 || model == 450 || model == 584 || model == 591 || model == 606 || model == 607 || model == 608 || model == 610 || model == 611)
{
return 1;
}
return 0;
}
stock IsAHelicopter(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 548 || model == 417 || model == 487 || model == 488 || model == 497 || model == 563 || model == 447 || model == 469)
{
return 1;
}
return 0;
}
stock IsATrain(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 449 || model == 537 || model == 538 || model == 569 || model == 570 || model == 590) return 1;
return 0;
}
stock IsATruck(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 403 || model == 407 || model == 443 || model == 455 || model == 514 || model == 515 || model == 524 || model == 544 || model == 578)
{
return 1;
}
return 0;
}
stock IsAnUnquine(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 406 || model == 444 || model == 486 || model == 530 || model == 531 || model == 532 || model == 539 || model == 556 || model == 557)
{
return 1;
}
return 0;
}
stock IsABoat(vehicleid)
{
new model = GetVehicleModel(vehicleid);
if(model == 430 || model == 446 || model == 452 || model == 453 || model == 454 || model == 472 || model == 473 || model == 484 || model == 493 || model == 595)
{
return 1;
}
return 0;
}
stock substr_count( substring[], string[] )
{
new tmpcount;
for( new i = 0; i < strlen( string ); i++)
{
if( strfind( string[ i ], substring, true ) )
{
tmpcount++;
}
}
return tmpcount;
}
#define iseven(%1) \
((((%1) / 2) * 2) == (%1))
#define isodd(%1) \
(!iseven((%1)))
stock split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
if(strsrc[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
/*----------------------------------------------------------------------------*-
Function:
StripNL
Params:
str[] - The string to remove the newline characters from
Return:
-
Notes:
Updated from old versions, should be more efficient
-*----------------------------------------------------------------------------*/
#define StripNewLine StripNL
stock StripNL(str[])
{
new
l = strlen(str);
while (l-- && str[l] <= ' ') str[l] = '\0';
}
stock fcopytextfile(oldname[],newname[]) {
new File:ohnd,File:nhnd;
if (!fexist(oldname)) return false;
ohnd=fopen(oldname,io_read);
nhnd=fopen(newname,io_write);
new tmpres[512];
while (fread(ohnd,tmpres)) {
StripNewLine(tmpres);
format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
fwrite(nhnd,tmpres);
}
fclose(ohnd);
fclose(nhnd);
return true;
}
stock frenametextfile(oldname[],newname[]) {
if (!fexist(oldname)) return false;
fremove(newname);
if (!fcopytextfile(oldname,newname)) return false;
fremove(oldname);
return true;
}
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Int=-1, VirtualWorld=-1){
new tmpcar = GetPlayerVehicleID(playerid);
if(tmpcar > 0){
SetVehiclePos(tmpcar, x, y, z);
if(Int>=0) LinkVehicleToInterior(tmpcar, Int);
if(VirtualWorld>=0) SetVehicleVirtualWorld(tmpcar, VirtualWorld);
}else{
SetPlayerPos(playerid, x, y, z);
if(Int>=0) SetPlayerInterior(playerid, Int);
if(VirtualWorld>=0) SetPlayerVirtualWorld(playerid, VirtualWorld);
}
return 1;
}
stock SetPlayerFacingAngleEx(playerid, Float:ang)
{
new tmpcar = GetPlayerVehicleID(playerid);
if(tmpcar) SetVehicleZAngle(tmpcar, ang);
else SetPlayerFacingAngle(playerid, ang);
SetCameraBehindPlayer(playerid);
return 1;
}
forward SetPlayerControllable(playerid);
forward PutPlayerInVehicleEx(playerid, vehicleid, seatid);
public SetPlayerControllable(playerid) TogglePlayerControllable(playerid, 1);
public PutPlayerInVehicleEx(playerid, vehicleid, seatid)
{
PutPlayerInVehicle(playerid, vehicleid, seatid);
return 1;
}