03/12/2023 21:42
Código PHP:
#include <a_samp>
enum pickupDrop {
pickupID,
pickupMoney,
Float:pickupPos[3],
pickupInterior,
pickupVirtualWorld
};
new PickupDrop[MAX_PLAYERS][pickupDrop];
public OnPlayerDisconnect(playerid, reason)
{
PickupDrop_Destroy(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PickupDrop_Create(playerid);
ResetPlayerMoney(playerid);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
static
id;
if((id = PickupDrop_Nearest(playerid)) != -1) {
GivePlayerMoney(playerid, PickupDrop[id][pickupMoney]);
PickupDrop_Destroy(id);
}
return 1;
}
PickupDrop_Create(playerid)
{
if(GetPlayerMoney(playerid) <= 0)
return 0;
if(IsValidDynamicPickup(PickupDrop[playerid][pickupID]))
DestroyDynamicPickup(PickupDrop[playerid][pickupID]);
GetPlayerPos(playerid, PickupDrop[playerid][pickupPos][0], PickupDrop[playerid][pickupPos][1], PickupDrop[playerid][pickupPos][2]);
PickupDrop[playerid][pickupInterior] = GetPlayerInterior(playerid);
PickupDrop[playerid][pickupVirtualWorld] = GetPlayerVirtualWorld(playerid);
PickupDrop[playerid][pickupMoney] = GetPlayerMoney(playerid) / 5;
PickupDrop[playerid][pickupID] = CreateDynamicPickup(1212, 4, PickupDrop[playerid][pickupPos][0] + random(2) - 1, PickupDrop[playerid][pickupPos][1] + random(2) - 1, PickupDrop[playerid][pickupPos][2] - 0.8, PickupDrop[playerid][pickupVirtualWorld], PickupDrop[playerid][pickupInterior]);
return 1;
}
PickupDrop_Nearest(playerid) {
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) if(IsPlayerConnected(i) {
if(IsPlayerInRangeOfPoint(playerid, 2.5, PickupDrop[playerid][pickupPos][0], PickupDrop[playerid][pickupPos][1], PickupDrop[playerid][pickupPos][2]) && GetPlayerInterior(playerid) == PickupDrop[playerid][pickupInterior] && GetPlayerVirtualWorld(playerid) && PickupDrop[playerid][pickupVirtualWorld])
return i;
}
return -1;
}
PickupDrop_Destroy(id) {
if(IsValidDynamicPickup(PickupDrop[playerid][pickupID]))
DestroyDynamicPickup(PickupDrop[playerid][pickupID]);
PickupDrop[id][pickupMoney] = 0;
PickupDrop[id][pickupPos][0] = 0.0;
PickupDrop[id][pickupPos][1] = 0.0;
PickupDrop[id][pickupPos][2] = 0.0;
PickupDrop[id][pickupInterior] = 0;
PickupDrop[id][pickupVirtualWorl] = 0;
return 1;
}
Fiz uma versão dessa forma, vê se ficou bom