weapon drop - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: weapon drop (
/showthread.php?tid=658340)
weapon drop -
severance - 02.09.2018
PHP код:
for(new i = 0; i < MAX_PICKUPS; i++) {
if(pickupid == DropInfo[i][ID] && DropInfo[i][ID] != -1) {
SetTimerEx("Health_Timer", 10000, false, "i", playerid);
if(DropInfo[i][Type] == 1) {
new Float: HP;
GetPlayerHealth(playerid, HP);
if(HP < 90) SetPlayerHealth(playerid, HP+10);
else SetPlayerHealth(playerid, 100);
}
else {
new gunname[32];
GetWeaponName(DropInfo[i][Weapon], gunname, sizeof(gunname));
GivePlayerWeapon(playerid, DropInfo[i][Weapon], DropInfo[i][Ammo]);
}
DestroyPickup(DropInfo[i][ID]);
Delete3DTextLabel(DropInfo[i][Label]);
DropInfo[i][Type] = 0;
DropInfo[i][ID] = -1;
}
}
PHP код:
function ResetPickups() {
for(new i = 0; i < MAX_PICKUPS; i++) {
if(DropInfo[i][ID] != -1) DropInfo[i][ID] = -1;
}
return 1;
}
function DestroyPickups() {
for(new i = 0; i < MAX_PICKUPS; i++) {
if(DropInfo[i][ID] != -1) {
DestroyPickup(DropInfo[i][ID]);
DropInfo[i][Type] = 0;
DropInfo[i][ID] = -1;
}
}
return 1;
}
function drop_player_weapons(playerid, type) {
new Float: Pos[3], gunname[32], sweapon,sammo, idd, result;
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
for(new i = 0; i < 12; i++) {
GetPlayerWeaponData(playerid, i, sweapon, sammo);
if(sweapon != 0) {
result++;
idd = CheckIDEmpty();
DropInfo[idd][ID] = CreatePickup(WeaponObject(sweapon), 23, Pos[0]+result, Pos[1]+2, Pos[2], -1);
DropInfo[idd][Type] = 0;
DropInfo[idd][Weapon] = sweapon;
DropInfo[idd][Ammo] = sammo;
GetWeaponName(sweapon, gunname, sizeof(gunname));
}
}
if(activeHeal == 1 && type == 0) {
result++;
idd = CheckIDEmpty();
DropInfo[idd][ID] = CreatePickup(1240, 23, Pos[0]+result, Pos[1]+2, Pos[2], -1);
DropInfo[idd][Type] = 1;
DropInfo[idd][Weapon] = 0;
DropInfo[idd][Ammo] = 0;
}
ResetPlayerWeapons(playerid);
return 1;
}
Using this drop, but whenever i take weapons that are dropped, after few seconds i get removed my weapons, it should actually remove the drop weapons but it appears that its removing even the players weaps who took it.
I think
PHP код:
ResetPlayerWeapons(playerid);
is what causes to to reset other players weaps.
Re: weapon drop -
Shinja - 02.09.2018
Show your Health_Timer function