21.06.2015, 16:26
Aborting an airdrop isn't very realistic, how come a player swallow the drop by pressing a key!
And that command /pickairdrop can very easily be made from OnPlayerKeyStateChange.
Here is the snippet:
And the message can be easily displayed when the airdrop is dropped on the ground, i.e. use SendClientMessage or anything else to notify players in OnObjectMoved.
And that command /pickairdrop can very easily be made from OnPlayerKeyStateChange.
Here is the snippet:
pawn Код:
CMD:pickairdrop(playerid)
{
//the player will be not allowed to pickup the airdrop while in a vehicle
if(! IsPlayerInAnyVehicle(playerid))
{
//looping through all airdrops
for(new i; i < MAX_AIRDROPS; i++)
{
//if the airdrop slot is occupied
//i.e. the airdrop exists
if(gAirdrop[i][a_exist])
{
//if the airdrop is on the ground, dropped
if(gAirdrop[i][a_droped])
{
//now using 'IsPlayerInRangeOfPoint', we will check if the player is near that airdrop
//The range is 5.0 and resonably fine. You may increase or decrease it if you wish
if(IsPlayerInRangeOfPoint(playerid, 5.0, gAirdrop[i][a_pos][0], gAirdrop[i][a_pos][1], gAirdrop[i][a_pos][2]))
{
//if the player is near the drop...
//We will apply a picking animation just for realisticity :)
ApplyAnimation(playerid, "MISC", "pickup_box", 1.0, 1, 1, 1, 1, 0);
//the gametext showing the player is picking the drop
GameTextForPlayer(playerid, "~b~~h~~h~~h~Picking...", 2000, 3);
//now we will make a timer to destroy the airdrop after 2 seconds
//the anim will be ovver by then
KillTimer(gAirdrop[i][a_expire_timer]);
gAirdrop[i][a_expire_timer] = SetTimerEx("OnPlayerPickupAirdrop", 2000, false, "ii", playerid, i);
gAirdrop[i][a_droped] = false;
//break the loop
break;
}
}
}
}
}
return 1;
}