OnPlayerDeath -
Mikkel_RE - 27.11.2012
Hey, i want to make that when you die you will drop all the weapons you have, but this code does only drop the weapon you are holding. can you help me with that?
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SecurityCam[playerid] = 0;
PissCounter[playerid] = 0;
if(gettime() - CarJackKilledAt[playerid] <= 10 || (PlayerInfo[playerid][pAdmin] & ADMIN_ACCESS && SpawnChange[playerid] == 4))
{
if(gettime() - CarJackKilledAt[playerid] > 10)
{
SaveHealth[playerid] = 100;
} else {
GetPlayerHealth(playerid,SaveHealth[playerid]);
}
GetPlayerArmour(playerid,SaveArmor[playerid]);
CarJackKilledAt[playerid] = 1;
GetPlayerPos(playerid,
adminResurrect[playerid][adX],
adminResurrect[playerid][adY],
adminResurrect[playerid][adZ]
);
GetPlayerFacingAngle(playerid,adminResurrect[playerid][adF]);
adminResurrect[playerid][adI] = GetPlayerInterior(playerid);
adminResurrect[playerid][adW] = GetPlayerVirtualWorld(playerid);
return 1;
}
new string[256];
if(PlayerPaintballing[playerid] != 0)
{
if(killerid != 65535)
{
PlayerPaintballKills[killerid] ++;
if(PlayerPaintballKills[killerid] > PaintballWinnerKills)
{
PaintballWinner = killerid;
PaintballWinnerKills = PlayerPaintballKills[killerid];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerPaintballing[i] != 0)
{
format(string, sizeof(string), "* %s is in the lead with %d kills.",Name(killerid),PaintballWinnerKills);
SendClientMessage(i, COLOR_WHITE, string);
}
}
}
}
}
return 1;
}
PlayerInfo[playerid][pIntoxication] = 0;
SetPlayerDrunkLevel(playerid,0);
//new dmessage[128];
//new deathreason[20];
new playercash;
new victimteam;
new killerteam;
if(PlayerInfo[playerid][pBanished]){
PlayerInfo[playerid][pArmor] = 0.0;
SetPlayerArmour(playerid,0.0);
RemoveWeapons(playerid);
return 1;
}
MedicBill[playerid] = 1;
new pdeathcash = GetMoney(playerid);
if(pdeathcash > 15000)
{
GiveMoney(playerid,-(pdeathcash - 15000));
}
if(PlayerInfo[playerid][pPot] > 10)
{
PlayerInfo[playerid][pPot] = 10;
}
if(PlayerInfo[playerid][pCrack] > 10)
{
PlayerInfo[playerid][pCrack] = 10;
}
new totalmats = PlayerInfo[playerid][pMats] + PlayerInfo[playerid][pMatsb] + PlayerInfo[playerid][pMatsc];
if(totalmats > 5000)
{
new Float:divisor = floatdiv(totalmats,5000);
PlayerInfo[playerid][pMats] = floatround(floatdiv(PlayerInfo[playerid][pMats],divisor),floatround_floor);
PlayerInfo[playerid][pMatsb] = floatround(floatdiv(PlayerInfo[playerid][pMatsb],divisor),floatround_floor);
PlayerInfo[playerid][pMatsc] = floatround(floatdiv(PlayerInfo[playerid][pMatsc],divisor),floatround_floor);
}
PlayerInfo[playerid][pArmor] = 0.0;
SetPlayerArmour(playerid,0.0);
RemoveWeapons(playerid);
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X, Y, Z);
DropWeapons(GetPlayerWeapon(playerid),GetPlayerAmmo(playerid),X,Y,Z,GetPlayerVirtualWorld(playerid),playerid);
SetPlayerWeapons(playerid);
AW: OnPlayerDeath -
Skimmer - 27.11.2012
But i don't see any script there for droping
any weapon.
Re: OnPlayerDeath -
Mikkel_RE - 27.11.2012
Here is the code for dropping weapons
pawn Код:
for(new i = 0; i < sizeof(DropInfo); i++)
{
if(DropInfo[i][dx] != 0.0 && DropInfo[i][dy] != 0.0 && DropInfo[i][dz] != 0.0)
{
if(DropInfo[i][dType] == 1)
{
if (DropInfo[i][dAmount][0] > 1 || DropInfo[i][dAmount][0] < 35)
{
DropObject[i] = CreateObject(gh_GetObjectID(DropInfo[i][dAmount][0]), DropInfo[i][dx], DropInfo[i][dy], DropInfo[i][dz]-1, 80.0, 0, 0, 200.0, DropInfo[i][dWorld]);
}
}
Re: OnPlayerDeath -
[KHK]Khalid - 27.11.2012
Replace
pawn Код:
DropWeapons(GetPlayerWeapon(playerid),GetPlayerAmmo(playerid),X,Y,Z,GetPlayerVirtualWorld(playerid),playerid);
with
pawn Код:
new weaponID[13], weaponammo[13];
for(int i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
DropWeapons(weaponID[i], weaponammo[i], X, Y, Z, GetPlayerVirtualWorld(playerid), playerid);
}
And you might want to put it before
RemoveWeapons(playerid);.
Re: OnPlayerDeath -
Mikkel_RE - 27.11.2012
I did that and now when im trying to compile it i get these errors
Код:
C:\Users\vMikkelReimer\Desktop\Samp stuff for 0,3d June-May2012\Samp crap 2012\gf_nov28.pwn(4401) : error 017: undefined symbol "int"
C:\Users\vMikkelReimer\Desktop\Samp stuff for 0,3d June-May2012\Samp crap 2012\gf_nov28.pwn(4401) : warning 215: expression has no effect
C:\Users\vMikkelReimer\Desktop\Samp stuff for 0,3d June-May2012\Samp crap 2012\gf_nov28.pwn(4401) : error 001: expected token: ")", but found ";"
C:\Users\vMikkelReimer\Desktop\Samp stuff for 0,3d June-May2012\Samp crap 2012\gf_nov28.pwn(4401) : error 036: empty statement
AW: OnPlayerDeath -
Skimmer - 27.11.2012
@HellSphinX tought he's scripting C++.
Fixed Version.
pawn Код:
new weaponID[13], weaponammo[13];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
DropWeapons(weaponID[i], weaponammo[i], X, Y, Z, GetPlayerVirtualWorld(playerid), playerid);
}
Re: OnPlayerDeath -
Mikkel_RE - 27.11.2012
Thanks it works!
Re: OnPlayerDeath -
[KHK]Khalid - 27.11.2012
Yeah, I got jumpled :P.
Note: Check
this next time you create a new topic on this section.