• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Server] Bug when player freezes
#12
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.

PHP Code:
new bool:freezedPlayer[MAX_PLAYERS];
new 
bool:canReceveidDamageFreezed[MAX_PLAYERS];

TogglePlayerControllableEx(playeridbool:statusbool:damage)
{
? ? 
canReceveidDamageFreezed[playerid] = damage;
if (
status == falsefreezedPlayer[playerid] = true;
else 
freezedPlayer[playerid] = false;
TogglePlayerControllable(playeridstatus);
}

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(playeridparams[])
{
? ? new 
id;
if (
sscanf(params"u"id))
{
return 
SendClientMessage(playeridCOLOR_INVALID"USE: /freeze [id]");
}
if (!
IsPlayerConnected(id) || id == INVALID_PLAYER_ID)
{
return 
SendClientMessage(playeridCOLOR_INVALID"Invalid Player");
}

? ? 
TogglePlayerControllableEx(idfalsetrue);
? ? return 
1;
}

public 
OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart)
{
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(damagedid0);
SetPlayerHealth(damagedidnewLife);
}
else
{
new 
Float:newArmour = (Armour amount);
SetPlayerArmour(damagedidnewArmour);
}
}
else
{
if (
amount Life)
{
CallLocalFunction("OnPlayerDeath""iii"damagedidplayeridGetPlayerWeapon(playerid));
SetPlayerHealth(damagedid100);
SpawnPlayer(damagedid);
}
else
{
new 
Float:newLife = (Life amount);
SetPlayerHealth(damagedidnewLife);
}
}
}
//
}
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.
  Reply


Messages In This Thread
Bug when player freezes - by RhaegarX - 2021-02-12, 08:18 PM
RE: Bug when player freezes - by Radical - 2021-02-12, 08:35 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 08:38 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 09:12 PM
RE: Bug when player freezes - by Radical - 2021-02-12, 09:27 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 09:34 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 09:35 PM
RE: Bug when player freezes - by Radical - 2021-02-12, 09:44 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 09:57 PM
RE: Bug when player freezes - by arber - 2021-02-12, 09:53 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-12, 09:58 PM
RE: Bug when player freezes - by RhaegarX - 2021-02-23, 01:37 AM

Forum Jump: