If you die armour stay.
#1

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);
Reply
#2

Quote:
Originally Posted by Ernestas_
Посмотреть сообщение
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:-

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerArmour(playerid, 100); // use this in OnPlayerSpawn so when a player spawn he spawn with an armour.
    return 1;
}
-FalconX
Reply
#3

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).
Reply
#4

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.
Reply
#5

Why would you want to keep armour after death <.<
Reply
#6

Quote:
Originally Posted by Ernestas_
Посмотреть сообщение
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.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:armour;
    GetPlayerArmour(playerid, armour);
    return 1;
}
and the other one is OnPlayerSpawn

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerArmour(playerid, armour);
    SendClientMessage(playerid, -1, "SERVER: Your armour has been restored.");
    return 1;
}
For more info have a look on https://sampwiki.blast.hk/wiki/GetPlayerArmour

Give it a try

-FalconX
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
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.
Reply
#8

That won't work because you're using local variables.

pawn Код:
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;
}
Reply
#9

Quote:
Originally Posted by MP2
Посмотреть сообщение
That won't work because you're using local variables.

pawn Код:
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
Reply
#10

Код:
D:\GangWorld\GM\gamemodes\perfect.pwn(187) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
187:
Код:
GetPVarFloat(playerid, "pArmour", pArmour);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)