OKStyle
| Дата: Вторник, 01.03.2011, 13:25 | Сообщение # 1 |
 Архивариус
Группа: Администраторы
Зарегистрирован: 19.02.2011
Сообщений: 125
Репутация: 8
Статус: Offline
| Инклюд с дополнительными функциями wFunctions. Подключаем так: Code #include <wFunctions> Содержимое инклюда: Code /* ///////////////////////////////////////////////////////////////// / FUNCTIONS TAKEN FROM VARIOUS FILTERSCRIPTS AND GAMEMODES / / I DONT CLAIM THIS AS MINE, I JUST ONLY PUT THEM TOGHETHER / / CREDITS GO TO EACH OF THE SCRIPTERS OF EACH FUNCTION / / / / PLEASE DON'T GET MAD IF YOU SEE A FUNCTION THAT YOU MADE / / AND THERE ARE NO CREDITS OF IT.. IT'S JUST THAT IS / / DIFFICULT TO SEARCH THE FORUM FOR EACH FUNCTION AND / / WHO DEVELOPED IT... CHEERS! / ///////////////////////////////////////////////////////////////// */
/*
Ok, here goes a little list of the functions included, sorted by type
*String Functions: - IsStringAName(string[]) - strtok(const string[], &index) - ValidEmail(email[]) - strlower(txt[]) - strupper(txt[]) - split(const strsrc[], strdest[][], delimiter) - StripNewLine(string[]) - equal(str1[],str2[],bool:ignorecase) *Distance Functions: - PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) - IsPlayerNearPos(playerID, Float:x, Float:y, Float:z, c) - GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &vehic) - GetPointDistanceToPoint(Float:x1,Float:y1,Float:x2,Float:y2) - GetPointDistanceToPointEx(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) - GetObjectToPlayerDistance(playerid, objectid) - GetDistanceFromPlayerToVehicle(playerid, vehicleid) - GetDistanceBetweenVehicles(vehicleid, vehicleid2) - GetDistanceBetweenPlayers(playerid, playerid2) - GetClosestPlayer(playerid)
*Coordinates Functions: - GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) - GetXYInFrontOfPosition(&Float:x, &Float:y, Float:a, Float:distance) - SetObjectToFaceCords(objectid, Float:x1, Float:y1, Float:z1) - IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy) - IsPlayerInCube(playerid, xmin, ymin, zmin, xmax, ymax, zmax)
*Convertion and Number Functions: - IsNumeric(const string[]) - HexToInt(string[]) - IntToHex(number) - StrToInt(string[]) - IntToStr(value) - Percent(Float:number, Float:percentage)
*File Functions: - fcopy(oldname[],newname[]) - frename(oldname[],newname[])
*Vehicle Functions: - GetVehicleDriver(vehicleid) - IsCopCar(carid) - IsBike(carid) - IsMotorBike(carid) - IsAirVehicle(carid) - IsABoat(carid) - IsPlayerInInvalidNosVehicle(playerid,vehicleid) - GivePlayerVehicle(playerid, vehicleid) - IsAnyTrailerAttachedToVehicle(vehicleid) - GetPlayersInVehicle(vehicleid) - IsInModVehicle(playerid) - DestroyVehicleSafely(vehicleid) - IsVehicleOccupied(vehicleid) - VehicleCount()
*Player Functions: - GetPlayerID(string[]) - IsPlayerSpawned(playerid) - GiveAllMoneyHealthArmour(money, Float:health, Float:armour) - GetAverageMoney() - TeleAllToPlayer(playerid) - GetOnlinePlayers() - GetHighestID() - Namesoff() - Nameson() - PlayerIp(playerid)
*Misc Functions: - IsValidSound(soundid) - IsValidWeapon(weaponid) - SetMapName(const mapname[]) */
//////////// // PlayerToPoint Function. To determine distance between the player and a given point. ////////////
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } return 0; }
//////////// // To determine a player's ID from a given Name ////////////
stock GetPlayerID(string[]) { for(new i = 0; i <= MAX_PLAYERS; i++) { if(IsPlayerConnected(i) == 1) { new testname[MAX_PLAYER_NAME]; GetPlayerName(i, testname, sizeof(testname)); if(strcmp(testname, string, true, strlen(string)) == 0) { return i; } } } return INVALID_PLAYER_ID; }
//////////// // To check if the given string is part of the name of a player. ////////////
stock IsStringAName(string[]) { for(new i = 0; i <= MAX_PLAYERS; i++) { if(IsPlayerConnected(i) == 1) { new testname[MAX_PLAYER_NAME]; GetPlayerName(i, testname, sizeof(testname)); if(strcmp(testname, string, true, strlen(string)) == 0) { return 1; } } } return 0; }
//////////// //To check if the given string is numeric or not. ////////////
stock IsNumeric(const string[]) { for (new i = 0, j = strlen(string); i < j; i++) if (string[i] > '9' || string[i] < '0') return 0; return 1; }
//////////// // Strtok, very common function for commands. ////////////
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; }
//////////// // Get the X and Y position in front of a player, depending where the player is looking at. ////////////
stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) { new Float:a; GetPlayerPos(playerid, x, y, a); if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a); else GetPlayerFacingAngle(playerid, a); x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); return a; }
//////////// // Get the X and Y position in front of a position. ////////////
stock GetXYInFrontOfPosition(&Float:x, &Float:y, Float:a, Float:distance) { x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); }
//////////// // To set the orientation of an object (mostly where it's aiming) ////////////
stock SetObjectToFaceCords(objectid, Float:x1, Float:y1, Float:z1) {
new Float:x2,Float:y2,Float:z2; GetObjectPos(objectid, x2,y2,z2);
new Float:DX = floatabs(x2-x1); new Float:DY = floatabs(y2-y1); new Float:DZ = floatabs(z2-z1);
new Float:yaw = 0; new Float:pitch = 0;
if(DY == 0 || DX == 0) { if(DY == 0 && DX > 0) { yaw = 00; pitch = 0; } else if(DY == 0 && DX < 0) { yaw = 180; pitch = 180; } else if(DY > 0 && DX == 0) { yaw = 90; pitch = 90; } else if(DY < 0 && DX == 0) { yaw = 270; pitch = 270; } else if(DY == 0 && DX == 0) { yaw = 0; pitch = 0; } } else { yaw = atan(DX/DY); pitch = atan(floatsqroot(DX*DX + DZ*DZ) / DY); if(x1 > x2 && y1 <= y2) { yaw = yaw + 90; pitch = pitch - 45; } else if(x1 <= x2 && y1 < y2) { yaw = 90 - yaw; pitch = pitch - 45; } else if(x1 < x2 && y1 >= y2) { yaw = yaw - 90; pitch = pitch - 45; } else if(x1 >= x2 && y1 > y2) { yaw = 270 - yaw; pitch = pitch + 315; } if(z1 < z2) pitch = 360-pitch; } SetObjectRot(objectid, 0, 0, yaw); SetObjectRot(objectid, 0, pitch, yaw+90); }
//////////// // Similar to PlayerToPoint? ////////////
stock IsPlayerNearPos(playerID, Float:x, Float:y, Float:z, c) { new Float:PX, Float:PY, Float:PZ;
GetPlayerPos(playerID, PX, PY, PZ); if((x-c < PX) && (x+c > PX) && (y-c < PY) && (y+c > PY) && (z-c < PZ) && (z+c > PZ)) { return 1; } return 0; }
//////////// // To determine if a player has entered an area defined by 2 points. ////////////
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); if (x > minx && x < maxx && y > miny && y < maxy) return 1; return 0; }
//////////// // To check for the closest vehicle in a certain range ////////////
stock GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &vehic) { for(new i = 1; i < MAX_VEHICLES; i++) { if(GetVehicleModel(i) > 0) { if(GetPlayerVehicleID(playerid) != i ) { new Float:x, Float:y, Float:z; new Float:x2, Float:y2, Float:z2; GetVehiclePos(i, x, y, z); x2 = x1 - x; y2 = y1 - y; z2 = z1 - z; new Float:iDist = (x2*x2+y2*y2+z2*z2); printf("Vehicle %d is %f", i, iDist);
if( iDist < dist) { vehic = i; } } } } }
//////////// // Returns the name of the player who's driving the vehicle ////////////
stock GetVehicleDriver(vehicleid) { for(new i; i<MAX_PLAYERS; i++) { if (IsPlayerInVehicle(i, vehicleid)) { if(GetPlayerState(i) == 2) { return i; } } } return -1; }
//////////// // To check if a player is inside a "cube" of point coordinates (Similar to IsPlayerInArea) ////////////
stock IsPlayerInCube(playerid, xmin, ymin, zmin, xmax, ymax, zmax) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); if( x > xmin && y > ymin && z > zmin && x < xmax && y < ymax && z < zmax) return 1; return 0; }
//////////// // Checks if a player has Spawned. ////////////
stock IsPlayerSpawned(playerid){ new statex = GetPlayerState(playerid); if(statex != PLAYER_STATE_NONE && statex != PLAYER_STATE_WASTED && statex != PLAYER_STATE_SPAWNED) return true; return false; }
//////////// // Vehicle Check functions by Andre9977 ////////////
stock IsCopCar(carid) { new Operative[] = { 523, 427, 490, 528, 596, 597, 598, 599 }; for(new i = 0; i < sizeof(Operative); i++) { if(GetVehicleModel(carid) == Operative[i]) return 1; } return 0; }
stock IsBike(carid) { new Bikes[] = { 509, 481, 510 }; for(new i = 0; i < sizeof(Bikes); i++) { if(GetVehicleModel(carid) == Bikes[i]) return 1; } return 0; }
stock IsMotorBike(carid) { new MotorBikes[] = { 581, 462, 521, 463, 522, 461, 448, 471, 468, 586 }; for(new i = 0; i < sizeof(MotorBikes); i++) { if(GetVehicleModel(carid) == MotorBikes[i]) return 1; } return 0; }
stock IsAirVehicle(carid) { new AirVeh[] = { 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 497, 563, 447, 469 }; for(new i = 0; i < sizeof(AirVeh); i++) { if(GetVehicleModel(carid) == AirVeh[i]) return 1; } return 0; }
stock IsABoat(carid) { new Boats[] = { 472, 473, 493, 495, 484, 430, 454, 453, 452, 446 }; for(new i = 0; i < sizeof(Boats); i++) { if(GetVehicleModel(carid) == Boats[i]) return 1; } return 0; }
//////////// // Checks if a player is in a valid NOS vehicle ////////////
stock IsPlayerInInvalidNosVehicle(playerid,vehicleid) { #define MAX_INVALID_NOS_VEHICLES 29
new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] = { 581,523,462,521,463,522,461,448,468,586, 509,481,510,472,473,493,595,484,430,453, 452,446,454,590,569,537,538,570,449 } ;
vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInVehicle(playerid,vehicleid)) { for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++) { if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i]) { return true; } } } return false; }
//////////// // Checks the distance between 2 given points by Boylett ////////////
stock Float:GetPointDistanceToPoint(Float:x1,Float:y1,Float:x2,Float:y2) { new Float:x, Float:y; x = x1-x2; y = y1-y2; return floatsqroot(x*x+y*y); }
//////////// // The same but checking Z too. ////////////
stock Float:GetPointDistanceToPointEx(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) { new Float:x, Float:y, Float:z; x = x1-x2; y = y1-y2; z = z1-z2; return floatsqroot(x*x+y*y+z*z); }
//////////// // Spawns a given vehicle to a given player ////////////
stock GivePlayerVehicle(playerid, vehicleid) { if(!IsPlayerInAnyVehicle(playerid) && vehicleid > 399 && vehicleid < 612) { new Float:x, Float:y, Float:z, Float:a, vehicle; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); vehicle = CreateVehicle(vehicleid, x, y, z, a, -1, -1, 50000); PutPlayerInVehicle(playerid, vehicle, 0); } }
//////////// // Gets the distance between a given player and a given object ////////////
stock GetObjectToPlayerDistance(playerid, objectid) { new Float:ox, Float:oy, Float:oz, Float:px, Float:py, Float:pz; new Float:distance; GetObjectPos(objectid, ox, oy, oz); GetPlayerPos(playerid, px, py, pz); distance = floatsqroot(floatpower(floatabs(floatsub(ox, px)),2)+floatpower(floatabs(floatsub(oy, py)),2)+floatpower(floatabs(floatsub(oz, pz)),2)); return floatround(distance); }
//////////// // Returns the distance between a given player and a given vehicle ////////////
stock GetDistanceFromPlayerToVehicle(playerid, vehicleid) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); GetVehiclePos(vehicleid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return floatround(tmpdis); }
//////////// // Returns the distance between 2 given vehicles ////////////
stock GetDistanceBetweenVehicles(vehicleid, vehicleid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetVehiclePos(vehicleid,x1,y1,z1); GetVehiclePos(vehicleid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return floatround(tmpdis); }
//////////// // Returns the distance between 2 given players ////////////
stock GetDistanceBetweenPlayers(playerid, playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); return floatround(tmpdis); }
//////////// // Returns the integer value of a given Hex number ////////////
stock HexToInt(string[]) { if (string[0]==0) return 0; new i; new cur=1; new res=0; for (i=strlen(string);i>0;i--) { if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10); cur=cur*16; } return res; }
//////////// // Returns the Hex value of a given Integer number ////////////
stock IntToHex(number) { new m=1; new depth=0; while (number>=m) { m = m*16; depth++; } depth--; new str[MAX_STRING]; for (new i = depth; i >= 0; i--) { str[i] = ( number & 0x0F) + 0x30; // + (tmp > 9 ? 0x07 : 0x00) str[i] += (str[i] > '9') ? 0x07 : 0x00; number >>= 4; } str[8] = '\0'; return str; }
//////////// // Returns the given String as Integer ////////////
stock StrToInt(string[]) { return strval(string); }
//////////// // Returns the given Integer as a String ////////////
stock IntToStr(value) { new tmp[MAX_STRING]; valstr(tmp, value); return tmp; }
//////////// // Checks if the given SoundID is a valid one ////////////
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; }
//////////// // Gives al the players the given Money, Health and Armour ////////////
stock GiveAllMoneyHealthArmour(money, Float:health, Float:armour) { for(new i=0; i<GetMaxPlayers(); i++) { new Float:pHealth, Float:pArmour; GetPlayerHealth(i, pHealth); GetPlayerArmour(i, pArmour); SetPlayerHealth(i, pHealth+health); SetPlayerArmour(i, pArmour+armour); GivePlayerMoney(i, money); } return true; }
//////////// // Gets the averga money from the server ////////////
stock GetAverageMoney() { new AverageMoney = 0; new PlayerCount = 0; for(new i = 0; i < GetMaxPlayers(); i++) { if(IsPlayerConnected(i)) continue; AverageMoney = AverageMoney + GetPlayerMoney(i); PlayerCount ++; } AverageMoney = AverageMoney / PlayerCount; return AverageMoney; }
//////////// // Returns true if a trailer is attached to a vehicle, otherwise false. ////////////
stock IsAnyTrailerAttachedToVehicle( vehicleid ) { switch ( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) ) { case 435, 450, 591, 606, 607, 610, 569, 590, 584, 570, 608, 611: return true; } return false; }
//////////// // Returns how many players are in a given vehicle ////////////
stock GetPlayersInVehicle(vehicleid) { new amount = 0; for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i) || !IsPlayerInVehicle(i,vehicleid)) continue; amount++; } return amount; }
//////////// // Teleports all players to a given player ////////////
stock TeleAllToPlayer(playerid) { for(new i=0;i<GetMaxPlayers();i++) { if(IsPlayerConnected(i)) { new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z); new rand;rand=random(5); SetPlayerPos(i,x+rand,y+rand,z+1); } } }
// Returns how many players are online
stock GetOnlinePlayers() { new count = 0; for(new i = 0; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i)) count = count + 1; return count; }
// Checks if a player is in a Moddable vehicle. By Kaisersouse
stock IsInModVehicle(playerid) { if(IsPlayerInAnyVehicle(playerid)) { new modmodel = GetVehicleModel(GetPlayerVehicleID(playerid)); switch(modmodel) { case 445,602,429,496,422,401,518,402,541,438, 527,415,542,589,480,507,585,419,587,533,526,466, 492,474,579,545,411,546,400,517,410,551,500,418, 516, 467,404,603,600,426,436,547,489,479,442,475,405,458, 580,439,409,550,506,566,549,420,451,540,491,412,478, 421,529,555,477,562,565,55 9,561,560, 558,536,575,534, 567,535,576: { return true; } } } return false; }
//////////// // Returns true if the given weaponID is valid. ////////////
stock IsValidWeapon(weaponid) { if (weaponid > 0 && weaponid < 19 || weaponid > 21 && weaponid < 47) { return 1; } return 0; }
//////////// // Returns who is the closest player to the given player. ////////////
stock GetClosestPlayer(playerid) { new Float:dis = 99999.99, Float:dis2, player = -1; for (new x = 0; x < GetMaxPlayers(); x++) { if (x != playerid) { dis2 = GetDistanceBetweenPlayers(x, playerid); if (dis2 < dis && dis2 != -1.00) { dis = dis2; player = x; } } } return player; }
//////////// // Destroys a vehicle safely to avoid Server crashes. By Andre9977 ////////////
stock DestroyVehicleSafely(vehicleid) { for(new i = 0; i < MAX_VEHICLES; i++) { if(!IsVehicleOccupied(vehicleid)) { DestroyVehicle(vehicleid); } } }
//////////// // Checks if there is any player on the given Vehicle ////////////
stock IsVehicleOccupied(vehicleid) { for(new i = 0; i < GetMaxPlayers(); i++) { if(IsPlayerInVehicle(i, vehicleid)) { return true; } } return false; }
//////////// // Gets the highest ID on the server ////////////
stock GetHighestID() { for(new i = GetMaxPlayers(); i >= -1; i--) { if(IsPlayerConnected(i) || i == -1) { return i; } } }
//////////// // Returns the percent of the 2 given numbers ////////////
stock Percent(Float:number, Float:percentage) { new Float:Sum; Sum = (number/100)*percentage; return floatround(Sum); }
//////////// // Checks if the given string is a valid Email adress. ////////////
stock ValidEmail(email[]) { new len=strlen(email); new cstate=0; new i; for(i=0;i<len;i++) { if ((cstate==0 || cstate==1) && (email[i]>='A' && email[i]<='Z') || (email[i]>='a' && email[i]<='z') || (email[i]=='.') || (email[i]=='-') || (email[i]=='_')) { } else { if ((cstate==0) &&(email[i]=='@')) { cstate=1; } else { return false; } } } if (cstate<1) return false; if (len<6) return false; if ((email[len-3]=='.') || (email[len-4]=='.') || (email[len-5]=='.')) return true; return false; }
//////////// // Copies a file. This doesn't delete the old one! ////////////
stock fcopy(oldname[],newname[]) { new File:ohnd,File:nhnd; if (!fexist(oldname)) return false; ohnd=fopen(oldname,io_read); nhnd=fopen(newname,io_write); new buf2[1]; new i; for (i=flength(ohnd);i>0;i--) { fputchar(nhnd, fgetchar(ohnd, buf2[0],false),false); } fclose(ohnd); fclose(nhnd); return true; }
//////////// // Renames a file. Note that this will erase the old one! ////////////
stock frename(oldname[],newname[]) { if (!fexist(oldname)) return false; fremove(newname); if (!fcopy(oldname,newname)) return false; fremove(oldname); return true; }
//////////// // returns the same string but Lowercased ////////////
stock strlower(txt[]) { new tmp[MAX_STRING]; tmp[0]=0; if (txt[0]==0) return tmp; new i=0; for (i=0;i<strlen(txt);i++) { tmp[i]=tolower(txt[i]); } tmp[strlen(txt)]=0; return tmp; }
//////////// // returns the same string but Uppercased ////////////
stock strupper(txt[]) { new tmp[MAX_STRING]; tmp[0]=0; if (txt[0]==0) return tmp; new i=0; for (i=0;i<strlen(txt);i++) { tmp[i]=toupper(txt[i]); } tmp[strlen(txt)]=0; return tmp; }
//////////// // This disables all player names. ////////////
stock Namesoff() { for(new i = 0; i < MAX_PLAYERS; i++) { ShowPlayerNameTagForPlayer(playerid, i, false); } }
//////////// // This enables all player names. ////////////
stock Nameson() { for(new i = 0; i < MAX_PLAYERS; i++) { ShowPlayerNameTagForPlayer(playerid, i, true); } }
//////////// // Splits the given String by a given Delimiter and saves it in a given String ////////////
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; }
//////////// // This clittle function just returns the player IP ////////////
stock PlayerIp(playerid) { new ip[16]; GetPlayerIp(playerid, ip, sizeof(ip)); return ip; }
//////////// // Counts how many vehicles are on the server ////////////
stock VehicleCount() { new iVehicleCnt; for( new i = 1; i < MAX_VEHICLES; i++ ) { if ( GetVehicleModel( i ) ) { iVehicleCnt++; } } return iVehicleCnt; }
//////////// // Sets the Map name. ////////////
stock SetMapName(const mapname[]) { new map[256]; format(map, sizeof(map), "mapname %s", mapname); SendRconCommand(map); }
//////////// // Strips Newline from the end of a string. ////////////
stock StripNewLine(string[]) { new len = strlen(string); if (string[0]==0) return ; if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) { string[len - 1] = 0; if (string[0]==0) return ; if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0; } }
//////////// // Checks wether two strings are equal (case insensetive) ////////////
stock equal(str1[],str2[],bool:ignorecase) { if (strlen(str1)!=strlen(str2)) return false; if (strcmp(str1,str2,ignorecase)==0) return true; return false; } Автор: Web
|
|
| |