| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- stock ClearChat(playerid)
- {
- for(new i; i < 20; i++) SendClientMessage(playerid, -1, " ");
- }
- stock bool:IsPlayerFacingPoint(playerid, Float:x, Float:y, Float:range = 10.0)
- {
- new Float:posX, Float:posY, Float:posZ;
- GetPlayerPos(playerid, posX, posY, posZ);
- new Float:facing;
- GetPlayerFacingAngle(playerid, facing);
- new Float:angle;
- if(posY > y ) angle = (-acos((posX - x) / floatsqroot((posX - x)*(posX - x) + (posY - y)*(posY - y))) - 90.0);
- else if( posY < y && posX < x ) angle = (acos((posX - x) / floatsqroot((posX - x)*(posX - x) + (posY - y)*(posY - y))) - 450.0);
- else if( posY < y ) angle = (acos((posX - x) / floatsqroot((posX - x)*(posX - x) + (posY - y)*(posY - y))) - 90.0);
- return (IsAngleInRangeOfAngle(-angle, facing, range));
- }
- stock bool:IsPlayerDoingAnimation(playerid)
- {
- if(GetPlayerSpecialAction(playerid) != 0) return true;
- switch(GetPlayerAnimationIndex(playerid))
- {
- case 454..471, 899..915, 1181..1183, 1185..1189, 1192, 1222..1235, 1249, 1256..1258, 1260..1272, 1275..1287, 1382..1386: return false;
- }
- return true;
- }
- stock bool:IsPlayerNearPlayer(playerid, targetid, Float:radius)
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- new matchingVW = GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid);
- new matchingInt = GetPlayerInterior(playerid) == GetPlayerInterior(targetid);
- new inRange = IsPlayerInRangeOfPoint(targetid, radius, x, y, z);
- return matchingVW && matchingInt && inRange;
- }
- stock bool:IsPlayerNearActor(playerid, actorid, Float:radius)
- {
- if(!Iter_Contains(StreamedActor[playerid], actorid)) return false;
- new Float:actorX, Float:actorY, Float:actorZ;
- GetActorPos(actorid, actorX, actorY, actorZ);
- if(!IsPlayerInRangeOfPoint(playerid, radius, actorX, actorY, actorZ)) return false;
- return true;
- }
- stock GetClosestActor(playerid, Float:range = FLOAT_INFINITY)
- {
- new Float:thisDist;
- new Float:actorX, Float:actorY, Float:actorZ;
- new Float:closestDist = FLOAT_INFINITY;
- new closestActor = INVALID_ACTOR_ID;
- foreach(new i : StreamedActor[playerid])
- {
- GetActorPos(i, actorX, actorY, actorZ);
- thisDist = GetPlayerDistanceFromPoint(playerid, actorX, actorY, actorZ);
- if(thisDist < closestDist && thisDist < range)
- {
- closestActor = i;
- closestDist = thisDist;
- }
- }
- return closestActor;
- }
- stock GetClosestPlayer(playerid, Float:range = FLOAT_INFINITY)
- {
- new Float:thisDist;
- new Float:x, Float:y, Float:z;
- new Float:closestDist = FLOAT_INFINITY;
- new closestPlayer = INVALID_PLAYER_ID;
- GetPlayerPos(playerid, x, y, z);
- foreach(new i : StreamedPlayer[playerid])
- {
- thisDist = GetPlayerDistanceFromPoint(i, x, y, z);
- if(thisDist < closestDist && thisDist < range)
- {
- closestPlayer = i;
- closestDist = thisDist;
- }
- }
- return closestPlayer;
- }
- stock GetClosestVehicle(playerid, Float:range = FLOAT_INFINITY)
- {
- new Float:thisDist;
- new Float:x, Float:y, Float:z;
- new Float:closestDist = FLOAT_INFINITY;
- new closestVehicle = INVALID_VEHICLE_ID;
- GetPlayerPos(playerid, x, y, z);
- foreach(new i : StreamedVehicle[playerid])
- {
- thisDist = GetVehicleDistanceFromPoint(i, x, y, z);
- if(thisDist < closestDist && thisDist < range)
- {
- closestVehicle = i;
- closestDist = thisDist;
- }
- }
- return closestVehicle;
- }
- stock SetPlayerToFacePlayer(playerid, targetid, Float:offset = 0.0)
- {
- new Float:x1, Float:y1, Float:z1;
- new Float:x2, Float:y2, Float:z2;
- GetPlayerPos(playerid, x1, y1, z1);
- GetPlayerPos(targetid, x2, y2, z2);
- SetPlayerFacingAngle(playerid, GetAngleToPoint(x1, y1, x2, y2) + offset);
- }
- stock SetPlayerToFacePoint(playerid, Float:x, Float:y)
- {
- new Float:pX, Float:pY, Float:pZ, Float:ang;
- GetPlayerPos(playerid, pX, pY, pZ);
- if(y > pY) ang = (-acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 90.0);
- else if(y < pY && x < pX) ang = (acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 450.0);
- else if(y < pY) ang = (acos((x - pX) / floatsqroot((x - pX)*(x - pX) + (y - pY)*(y - pY))) - 90.0);
- if(x > pX) ang = (floatabs(floatabs(ang) + 180.0));
- else ang = (floatabs(ang) - 180.0);
- SetPlayerFacingAngle(playerid, ang);
- return false;
- }
- stock SetPlayerToFaceDynamicActor(playerid, targetid)
- {
- new Float:x1, Float:y1, Float:z1;
- new Float:x2, Float:y2, Float:z2;
- GetPlayerPos(playerid, x1, y1, z1);
- GetDynamicActorPos(targetid, x2, y2, z2);
- SetPlayerFacingAngle(playerid, GetAngleToPoint(x1, y1, x2, y2));
- }
- stock bool:IsAngleInRangeOfAngle(Float:a1, Float:a2, Float:range = 10.0)
- {
- a1 -= a2;
- if((a1 < range) && (a1 > -range)) return true;
- return false;
- }
- // Truncates a value to the range 0.0 - 360.0
- stock Float:GetAbsoluteAngle(Float:angle)
- {
- while(angle < 0.0)
- {
- angle += 360.0;
- }
- while(angle > 360.0)
- {
- angle -= 360.0;
- }
- return angle;
- }
- // Returns the offset heading from north between a point and a destination
- stock Float:GetAngleToPoint(Float:fPointX, Float:fPointY, Float:fDestX, Float:fDestY)
- {
- return GetAbsoluteAngle(-(90.0 - (atan2((fDestY - fPointY), (fDestX - fPointX)))));
- }
- #include <YSI_Coding\y_hooks>
- static const AnimData[][] =
- {
- "AIRPORT", "ATTRACTORS", "BAR", "BASEBALL", "BD_FIRE",
- "BEACH", "BENCHPRESS", "BF_INJECTION", "BIKE_DBZ", "BIKED",
- "BIKEH", "BIKELEAP", "BIKES", "BIKEV", "BLOWJOBZ",
- "BMX", "BOMBER", "BOX", "BSKTBALL", "BUDDY",
- "BUS", "CAMERA", "CAR", "CAR_CHAT", "CARRY",
- "CASINO", "CHAINSAW", "CHOPPA", "CLOTHES", "COACH",
- "COLT45", "COP_AMBIENT", "COP_DVBYZ", "CRACK", "CRIB",
- "DAM_JUMP", "DANCING", "DEALER", "DILDO", "DODGE",
- "DOZER", "DRIVEBYS", "FAT", "FIGHT_B", "FIGHT_C",
- "FIGHT_D", "FIGHT_E", "FINALE", "FINALE2", "FLAME",
- "FLOWERS", "FOOD", "FREEWEIGHTS", "GANGS", "GFUNK",
- "GHANDS", "GHETTO_DB", "GOGGLES", "GRAFFITI", "GRAVEYARD",
- "GRENADE", "GYMNASIUM", "HAIRCUTS", "HEIST9", "INT_HOUSE",
- "INT_OFFICE", "INT_SHOP", "JST_BUISNESS", "KART", "KISSING",
- "KNIFE", "LAPDAN1", "LAPDAN2", "LAPDAN3", "LOWRIDER",
- "MD_CHASE", "MD_END", "MEDIC", "MISC", "MTB",
- "MUSCULAR", "NEVADA", "ON_LOOKERS", "OTB", "PARACHUTE",
- "PARK", "PAULNMAC", "PED", "PLAYER_DVBYS", "PLAYIDLES",
- "POLICE", "POOL", "POOR", "PYTHON", "QUAD",
- "QUAD_DBZ", "RAPPING", "RIFLE", "RIOT", "ROB_BANK",
- "ROCKET", "RUNNINGMAN", "RUSTLER", "RYDER", "SCRATCHING",
- "SEX", "SHAMAL", "SHOP", "SHOTGUN", "SILENCED",
- "SKATE", "SMOKING", "SNIPER", "SNM", "SPRAYCAN",
- "STRIP", "SUNBATHE", "SWAT", "SWEET", "SWIM",
- "SWORD", "TANK", "TATTOOS", "TEC", "TRAIN",
- "TRUCK", "UZI", "VAN", "VENDING", "VORTEX",
- "WAYFARER", "WEAPONS", "WOP", "WUZI"
- };
- hook OnPlayerConnect(playerid)
- {
- for(new i = 0; i < sizeof(AnimData); i++) ApplyAnimation(playerid, AnimData[i], "null", 4.0, 0, 0, 0, 0, 0, 1);
- }
|