forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 2.0, x2,y2,z2)){ SendClientMessage(playerid, piros, \"(( Nincs a közeledben! ))\"); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; }}} return targetid;}
stock Float:GetDistanceToPlayer(playerid,playerid2){ new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; if (!IsPlayerConnected(playerid) || !IsPlayerConnected(playerid2)) { return -1.00; } GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));}stock ClosestPlayer(p1){ new Float:dis,Float:dis2,playerid; playerid = -1; dis = 99999.99; foreach(Player,i){ dis2 = GetDistanceToPlayer(p1, i); if(dis2 < dis && dis2 != -1.00) { dis = dis2; playerid = i; }} return playerid;}
forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 2.0, x2,y2,z2)) { tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; } } else targetid = -1;if( targetid == -1 ) SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");} return targetid;}
Sajnos nem volt alkalmam tesztelni, de próbáld meg így! forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 2.0, x2,y2,z2)) { tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; } } else targetid = -1;if( targetid == -1 ) SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");} return targetid;}
forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 2.0, x2,y2,z2)) { tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; } } else targetid = -1;}if( targetid != -1 ) return targetid;else return SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");}
forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 4.0, x2,y2,z2)) { tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; } } else targetid = -1; } if( targetid == -1 ) SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\"); return targetid;}
CMD:bilincsel(playerid, params[]){if(admins[playerid][frakcio] == 4 || admins[playerid][frakcio] == 5 ||admins[playerid][frakcio] == 6 || admins[playerid][frakcio] == 7 || admins[playerid][frakcio] == 8 || admins[playerid][frakcio] == 9 || admins[playerid][frakcio] == 10 || admins[playerid][frakcio] == 11 || admins[playerid][frakcio] == 12 || admins[playerid][frakcio] == 13 ||admins[playerid][frakcio] == 14 || admins[playerid][frakcio] == 15 ||admins[playerid][frakcio] == 16 || admins[playerid][frakcio] == 17 || admins[playerid][frakcio] == 36 || admins[playerid][frakcio] == 37 || admins[playerid][frakcio] == 38 || admins[playerid][frakcio] == 39 || admins[playerid][frakcio] == 40){ if(szolg[playerid] == 1) { new playes = GetClosestPlayerToPlayer(playerid); if(bilincsbe[playes] == 0) { TogglePlayerControllable(playes,0); SetPlayerSpecialAction(playes, SPECIAL_ACTION_CUFFED); SetPlayerAttachedObject(playes, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000); SendClientMessage(playes,piros,\"(( Egy rendõr megbilincsel. ))\"); SendClientMessage(playerid,narancssárga,\"(( Megbilincseltél valakit. ))\"); cmd_me(playerid,\"megbilincselt valakit.\"); bilincsbe[playes] = 1; } else SendClientMessage(playerid, piros,\"(( Õ már meg van bilincselve! ))\");} else SendClientMessage(playerid, piros,\"(( Nem vagy szolgálatban! ))\");} else return 0;return 1;}
Ez már majdnem jó egy kicsi belejavítással.Most az a probléma, hogy, ha megbilincseltem valakit és utána próbálom mindenkitõl messze akkor ismeretlen parancsot ad és azt is írja, hogy senki nincs a közelembe.
} if( targetid == -1 ) SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");
} if( targetid == -1 ) return SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");
if(admins[playerid][frakcio] == 4 || admins[playerid][frakcio] == 5 ||admins[playerid][frakcio] == 6 || admins[playerid][frakcio] == 7 || admins[playerid][frakcio] == 8 || admins[playerid][frakcio] == 9 || admins[playerid][frakcio] == 10 || admins[playerid][frakcio] == 11 || admins[playerid][frakcio] == 12 || admins[playerid][frakcio] == 13 ||admins[playerid][frakcio] == 14 || admins[playerid][frakcio] == 15 ||admins[playerid][frakcio] == 16 || admins[playerid][frakcio] == 17 || admins[playerid][frakcio] == 36 || admins[playerid][frakcio] == 37 || admins[playerid][frakcio] == 38 || admins[playerid][frakcio] == 39 || admins[playerid][frakcio] == 40)
switch(admins[playerid][frakcio]){ case 4,5,6,7,8,9,10,11,12,13,14,15,16,17,36,37,38,39,40: { //Ide jöjjön a parancs többi része, ami eddig az óriási if alatt volt. }}
CMD:bilincsel(playerid, params[]){if(admins[playerid][frakcio] == 4 || admins[playerid][frakcio] == 5 ||admins[playerid][frakcio] == 6 || admins[playerid][frakcio] == 7 || admins[playerid][frakcio] == 8 || admins[playerid][frakcio] == 9 || admins[playerid][frakcio] == 10 || admins[playerid][frakcio] == 11 || admins[playerid][frakcio] == 12 || admins[playerid][frakcio] == 13 ||admins[playerid][frakcio] == 14 || admins[playerid][frakcio] == 15 ||admins[playerid][frakcio] == 16 || admins[playerid][frakcio] == 17 || admins[playerid][frakcio] == 36 || admins[playerid][frakcio] == 37 || admins[playerid][frakcio] == 38 || admins[playerid][frakcio] == 39 || admins[playerid][frakcio] == 40){ if(szolg[playerid] == 1) { new playes = GetClosestPlayerToPlayer(playerid); if(bilincsbe[playes] == 0) { TogglePlayerControllable(playes,0); SetPlayerSpecialAction(playes, SPECIAL_ACTION_CUFFED); SetPlayerAttachedObject(playes, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000); SendClientMessage(playes,piros,\"(( Egy rendõr megbilincsel. ))\"); SendClientMessage(playerid,narancssárga,\"(( Megbilincseltél valakit. ))\"); cmd_me(playerid,\"megbilincselt valakit.\"); bilincsbe[playes] = 1; } else SendClientMessage(playerid, piros,\"(( Õ már meg van bilincselve! ))\");} else SendClientMessage(playerid, piros,\"(( Nem vagy szolgálatban! ))\");} else return 0;return 1;}forward GetClosestPlayerToPlayer(playerid);public GetClosestPlayerToPlayer(playerid){ new Float:dist = 1000.0; new targetid = INVALID_PLAYER_ID; new Float:x1,Float:y1,Float:z1; new Float:x2,Float:y2,Float:z2; new Float:tmpdis; GetPlayerPos(playerid,x1,y1,z1); for(new i=0;i<MAX_PLAYERS;i++) { if(i == playerid) continue; GetPlayerPos(i,x2,y2,z2); if(IsPlayerInRangeOfPoint(playerid, 4.0, x2,y2,z2)) { tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); if(tmpdis < dist) { dist = tmpdis; targetid = i; } } else targetid = -1; }if(targetid == -1) return SendClientMessage(playerid, piros, \"(( Senki nincs a közeledben! ))\");return targetid;}
stock LegkozelebbiJatekos(playerid, Float:korzet){new Float:jpoz[3], Float:tav = korzet, legkjatekos;for(new a = 0; a < LegfJatekos; a++){if(!IsPlayerConnected(a)) continue;if(a == playerid) continue;if(GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(a)) continue;if(GetPlayerInterior(playerid) != GetPlayerInterior(a)) continue;GetPlayerPos(a, jpoz[0], jpoz[1], jpoz[2]);if(GetPlayerDistanceFromPoint(playerid, jpoz[0], jpoz[1], jpoz[2]) > tav) continue; else{ tav = GetPlayerDistanceFromPoint(playerid, jpoz[0], jpoz[1], jpoz[2]); legkjatekos = a;}}if(tav < korzet) return legkjatekos;else return -1;}
CMD:bilincsel(playerid){switch(admins[playerid][frakcio]){case 4,5,6,7,8,9,10,11,12,13,14,15,16,17,36,37,38,39,40:{ if(szolg[playerid] != 1) return SendClientMessage(playerid, piros, \"(( Nem vagy szolgálatban! ))\"); new bilincselt = LegkozelebbiJatekos(playerid, 2.5); if(bilincselt == -1) return SendClientMessage(playerid, piros, \"(( Nincs a közeledben senki! ))\"); if(bilincsbe[bilincselt] != 0) return SendClientMessage(playerid, piros, \"(( Õ már meg van bilincselve! ))\"); bilincsbe[bilincselt] = 1; TogglePlayerControllable(bilincselt, 0); SetPlayerSpecialAction(bilincselt, SPECIAL_ACTION_CUFFED); SetPlayerAttachedObject(bilincselt, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000); SendClientMessage(bilincselt, piros, \"(( Egy rendõr megbilincselt. ))\"); SendClientMessage(playerid, narancssárga, \"(( Megbilincseltél valakit. ))\"); cmd_me(playerid, \"megbilincselt valakit.\"); } default: return SendClientMessage(playerid, piros, \"(( Nem vagy megfelelõ frakcióban! ))\");}return 1;}