Sorry for remembering this topic, but I need to clear up some doubts.
I used the include weapon-config mentioned above, but I didn't like the modifications it carries with it. So I decided to develop my own solution to the problem of that topic.
Pastebin:?Code SAMP - Pastebin.com
That way I can control when the player can take damage or not when frozen, what I would like to know is if there is any problem with me calling OnPlayerDeath to simulate a false death as I used in the code above, instead of causing death effectively.
I used the include weapon-config mentioned above, but I didn't like the modifications it carries with it. So I decided to develop my own solution to the problem of that topic.
PHP Code:
new bool:freezedPlayer[MAX_PLAYERS];
new bool:canReceveidDamageFreezed[MAX_PLAYERS];
TogglePlayerControllableEx(playerid, bool:status, bool:damage)
{
? ? canReceveidDamageFreezed[playerid] = damage;
if (status == false) freezedPlayer[playerid] = true;
else freezedPlayer[playerid] = false;
TogglePlayerControllable(playerid, status);
}
public OnPlayerConnect(playerid)
{
? ? freezedPlayer[playerid] = false;
canReceveidDamageFreezed[playerid] = false;
}
public OnPlayerSpawn(playerid)
{
? ? freezedPlayer[playerid] = false;
}
// This command is just an example of the server command itself.
CMD:freeze(playerid, params[])
{
? ? new id;
if (sscanf(params, "u", id))
{
return SendClientMessage(playerid, COLOR_INVALID, "USE: /freeze [id]");
}
if (!IsPlayerConnected(id) || id == INVALID_PLAYER_ID)
{
return SendClientMessage(playerid, COLOR_INVALID, "Invalid Player");
}
? ? TogglePlayerControllableEx(id, false, true);
? ? return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
if (playerid != INVALID_PLAYER_ID)
{
// Corrigi o Dano em Roubo e Lavagem de Dinheiro
if (freezedPlayer[damagedid] == true && canReceveidDamageFreezed[damagedid] == true)
{
if (Armour > 0)
{
if (amount > Armour)
{
new Float:leftDamage = (amount - Armour), Float:newLife = (Life - leftDamage);
SetPlayerArmour(damagedid, 0);
SetPlayerHealth(damagedid, newLife);
}
else
{
new Float:newArmour = (Armour - amount);
SetPlayerArmour(damagedid, newArmour);
}
}
else
{
if (amount > Life)
{
CallLocalFunction("OnPlayerDeath", "iii", damagedid, playerid, GetPlayerWeapon(playerid));
SetPlayerHealth(damagedid, 100);
SpawnPlayer(damagedid);
}
else
{
new Float:newLife = (Life - amount);
SetPlayerHealth(damagedid, newLife);
}
}
}
//
}
return 1;
}
Pastebin:?Code SAMP - Pastebin.com
That way I can control when the player can take damage or not when frozen, what I would like to know is if there is any problem with me calling OnPlayerDeath to simulate a false death as I used in the code above, instead of causing death effectively.