25.09.2009, 12:51
Quote:
Originally Posted by virspector
First, put this forward:
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); forward IsVehicleNearToPos(vehicleid, playerid); Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { if(IsPlayerConnected(playerid)) { 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); //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } } return 0; } Код:
public IsVehicleNearToPos(vehicleid, playerid) { new Float:x, Float:y, Float:z; GetVehiclePos(vehicleid, x, y, z); if(PlayerToPoint(20, playerid, x, y, z); //Change the 20 into the radius beetween player and vehicle { return 1; } else { return 0; } } Код:
IsVehicleNearToPos(<vehicleid>, <playerid>); Код:
OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp("/isplanenearpos", cmdtext, true)) { if(IsVehicleNearToPos(2, playerid)) //Let's just say the "PLANE" id is 2 { SendClientMessage(playerid, COLOR_SYSTEM, "Yes, it is"); } else { SendClientMessage(playerid, COLOR_SYSTEM, "No, it is not"); } } } |
Ok, let's just change some of the things...
Add these forwards:
Код:
forward VehicleToPoint(Float:radi, vehicleid, Float:x, Float:y, Float:z); forward IsVehicleNearToPos(vehicleid, x, y, z);
Код:
public VehicleToPoint(Float:radi, vehicleid, Float:x, Float:y, Float:z) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetVehiclePos(vehicleid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } return 0; }
Код:
public IsVehicleNearToPos(vehicleid, x, y, z) { if(VehicleToPoint(10, vehicleid, x, y, z); //Change the 10 into the radius between the coordinate and vehicle { return 1; } else { return 0; } }
Код:
IsVehicleNearToPos(vehicleid, x, y, z);
Sorry, i didn't test it yet, but i am sure 95% it works correctly