10.05.2012, 06:02
Ok, basically i want to know how i would go about detecting if a player is standing on the ground. (rather than mid air jumping or falling from a building)
stock Float:Distance3D(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, bool:sqrt = false) { x1 -= x2; x1 *= x1; y1 -= y2; y1 *= y1; z1 -= z2; z1 *= z1; x1 += y1; x1 += z1; return sqrt ? floatsqroot(x1) : x1; } public OnPlayerUpdate(playerid) { new Float:Cx,Float:Cy,Float:Cz; GetPlayerPos(playerid,Cx,Cy,Cz); if (Distance3D(GetPVarFloat(playerid,"xpos"),GetPVarFloat(playerid,"ypos"),GetPVarFloat(playerid,"zpos"),Cx,Cy,Cz)>0.01) { SetPVarInt(playerid, "moving", 1); } else { SetPVarInt(playerid, "moving", 0); } SetPVarFloat(playerid,"xpos",Cx); SetPVarFloat(playerid,"ypos",Cy); SetPVarFloat(playerid,"zpos",Cz); return 1; }
if (GetPVarInt(playerid, "moving")==1) { //... Do somthing }