PDA

View Full Version : If you die armour stay.


Ernestas_
27/04/2012, 09:40 AM
Hi. I have problem with "If player dies, armor stay". How can I do it? I tried this:

new Float:deatharmor; // At the top

public OnPlayerDeath(playerid, killerid, reason)
deatharmor = GetPlayerArmour(playerid);
and
public OnPlayerSpawn( playerid )
SetPlayerArmour(playerid, deatharmor);

FalconX
27/04/2012, 09:48 AM
Hi. I have problem with "If player dies, armor stay". How can I do it? I tried this:

new Float:deatharmor; // At the top

public OnPlayerDeath(playerid, killerid, reason)
deatharmor = GetPlayerArmour(playerid);
and
public OnPlayerSpawn( playerid )
SetPlayerArmour(playerid, deatharmor);

You want a person to stay with an armour? like when he dies and respawn he must have the armour? If that so use the following:-


public OnPlayerSpawn(playerid)
{
SetPlayerArmour(playerid, 100); // use this in OnPlayerSpawn so when a player spawn he spawn with an armour.
return 1;
}


-FalconX

MP2
27/04/2012, 09:52 AM
Well, if you have armour and take damage from someone, it depletes, so how can it 'stay'? You can't die while having armour (well, certain circumstances i.e. fire I think and vehicle collisions).

Ernestas_
27/04/2012, 09:58 AM
Armor don't disappear then u fall and etc. I need that if u had 50 armour, when u fall or smth after death u will get 50 armour.

MP2
27/04/2012, 10:01 AM
Why would you want to keep armour after death <.<

FalconX
27/04/2012, 10:02 AM
Armor don't disappear then u fall and etc. I need that if u had 50 armour, when u fall or smth after death u will get 50 armour.

Okay, I will write a code for you, as I'm on my ipad don't blame me for mistakes.


public OnPlayerDeath(playerid, killerid, reason)
{
new Float:armour;
GetPlayerArmour(playerid, armour);
return 1;
}


and the other one is OnPlayerSpawn


public OnPlayerSpawn(playerid)
{
SetPlayerArmour(playerid, armour);
SendClientMessage(playerid, -1, "SERVER: Your armour has been restored.");
return 1;
}


For more info have a look on http://wiki.sa-mp.com/wiki/GetPlayerArmour

Give it a try

-FalconX

Ernestas_
27/04/2012, 10:07 AM
Why would you want to keep armour after death <.<

In my server only high lvl people can get armour, and can get armour not always.

FalconX, i will try it soon.

MP2
27/04/2012, 10:11 AM
That won't work because you're using local variables.


public OnPlayerDeath(playerid, killerid, reason)
{
new Float:pArmour;
GetPlayerArmour(playerid, pArmour);
SetPVarFloat(playerid, "pArmour", pArmour);
return 1;
}

public OnPlayerSpawn(playerid)
{
new Float:pArmour;
GetPVarFloat(playerid, "pArmour", pArmour);
SetPlayerArmour(playerid, pArmour);
return 1;
}

FalconX
27/04/2012, 10:35 AM
That won't work because you're using local variables.


public OnPlayerDeath(playerid, killerid, reason)
{
new Float:pArmour;
GetPlayerArmour(playerid, pArmour);
SetPVarFloat(playerid, "pArmour", pArmour);
return 1;
}

public OnPlayerSpawn(playerid)
{
new Float:pArmour;
GetPVarFloat(playerid, "pArmour", pArmour);
SetPlayerArmour(playerid, pArmour);
return 1;
}


Oh ok Thanks for correcting me :)

Ernestas_
27/04/2012, 10:39 AM
D:\GangWorld\GM\gamemodes\perfect.pwn(187) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.


187: GetPVarFloat(playerid, "pArmour", pArmour);

Pinguinn
27/04/2012, 10:51 AM
GetPVarFloat(playerid, "pArmour");

fordawinzz
27/04/2012, 10:52 AM
SetPlayerArmour(playerid, GetPVarFloat(playerid, "pArmour"));
or


new Float: pArmour;
pArmour = GetPVarFloat(playerid, "pArmour");
SetPlayerArmour(playerid, pArmour);

Marco_Valentine
27/04/2012, 11:04 AM
Top of script
new Float:Armour[MAX_PLAYERS];

OnPlayerDeath:
GetPlayerArmour(playerid,Armour[playerid]);

OnPlayerSpawn:
SetPlayerArmour(playerid,Armour[playerid]);

Youice
27/04/2012, 11:16 AM
public OnPlayerDeath(playerid, killerid, reason)
{
for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
{
new Float:ar;
ar = GetPlayerArmour(i, ar);
SetPlayerArmour(i, ar);
}
/*
SetPlayerArmour(playerid, 100);
*/
return 1;
}


try this if didn't work add the code under /* */ hope it work

Ernestas_
27/04/2012, 11:30 AM
SetPlayerArmour(playerid, GetPVarFloat(playerid, "pArmour"));
or


new Float: pArmour;
pArmour = GetPVarFloat(playerid, "pArmour");
SetPlayerArmour(playerid, pArmour);


Thanks, your code works. Thanks everyone for help :)

Marco_Valentine
27/04/2012, 11:31 AM
^ wouldn't work? I suggest using what i put there because it will work....

SuperViper
27/04/2012, 02:22 PM
I believe armor is reset when a player dies. So use this:

new Float: LastPlayerArmor[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
LastPlayerArmor[playerid] = 0;
return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid == INVALID_PLAYER_ID)
{
new Float: curHealth;
GetPlayerHealth(playerid, curHealth);
if(!curHealth)
{
GetPlayerArmour(playerid, LastPlayerArmor[playerid]);
}
}
else
{
LastPlayerArmor[playerid] = 0;
}
return 1;
}

public OnPlayerSpawn(playerid)
{
SetPlayerArmour(playerid, LastPlayerArmor[playerid]);
return 1;
}