• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Server] Bug when player freezes
#1
I am developing a stealing system, in which when stealing the player is frozen [TogglePlayerControllable (playerid, false);].
However, when the player is frozen he becomes immortal, not taking any damage.
Can anyone tell me how to fix this bug?
  Reply
#2
Why do you freeze player?
You can apply an animation instead.
  Reply
#3
(2021-02-12, 08:35 PM)Radical Wrote: Why do you freeze player?

You can apply an animation instead.



to also lock the player's camera. This bug occurs in any code that uses the player freeze function, as in the / freeze command for administrators
  Reply
#4
I really tried to analyze everything in gamemode, but I can't solve this bug
  Reply
#5
I think in include weapon-config, this has been fixed.

But this include, changes the damaging to player algorithm a lot...
  Reply
#6
(2021-02-12, 09:27 PM)Radical Wrote: I think in include weapon-config, this has been fixed.

But this include, changes the damaging to player algorithm a lot...



I will test this include, but in the case I wanted to solve this without resorting to includes.

Could some other include from my gamemode be causing the problem?



PHP Code:
#include? ? <a_samp>

#define FIXES_Single 1

#define FIXES_ServerVarMsg 0

// Redefini??es antes da Fixes

#if? ? ? defined MAX_PLAYERS

#undef? ? MAX_PLAYERS

#define? MAX_PLAYERS? (100)

#endif

//

#include <fixes>

#include? ? <timerfix>

#include? ? <a_mysql>

#include? ? <foreach>

#include? ? <zcmd>

#include? ? <sscanf2>

#include? ? <MV_Youtube>

#include? ? <streamer>

#include? ? <callbacks>

#include? ? <mSelection>

#define AUTO_SETUP

#include? ? <gmtime> 
  Reply
#7
(2021-02-12, 09:34 PM)RhaegarX Wrote:
(2021-02-12, 09:27 PM)Radical Wrote: I think in include weapon-config, this has been fixed.

But this include, changes the damaging to player algorithm a lot...



I will test this include, but in the case I wanted to solve this without resorting to includes.

Could some other include from my gamemode be causing the problem?



PHP Code:
#include? ? <a_samp>

#define FIXES_Single 1

#define FIXES_ServerVarMsg 0

// Redefini??es antes da Fixes

#if? ? ? defined MAX_PLAYERS

#undef? ? MAX_PLAYERS

#define? MAX_PLAYERS? (100)

#endif

//

#include <fixes>

#include? ? <timerfix>

#include? ? <a_mysql>

#include? ? <foreach>

#include? ? <zcmd>

#include? ? <sscanf2>

#include? ? <MV_Youtube>

#include? ? <streamer>

#include? ? <callbacks>

#include? ? <mSelection>

#define AUTO_SETUP

#include? ? <gmtime> 





I already removed all the code from OnPlayerGiveDamage and OnPlayerWeaponShot to try to find out if there was a problem with them, but the problem continued



[Image: X1QTrFp.png]
  Reply
#8
(2021-02-12, 09:34 PM)RhaegarX Wrote:
(2021-02-12, 09:27 PM)Radical Wrote: I think in include weapon-config, this has been fixed.
But this include, changes the damaging to player algorithm a lot...

I will test this include, but in the case I wanted to solve this without resorting to includes.
Could some other include from my gamemode be causing the problem?

PHP Code:
#include? ? <a_samp>
#define FIXES_Single 1
#define FIXES_ServerVarMsg 0
// Redefini??es antes da Fixes
#if? ? ? defined MAX_PLAYERS
#undef? ? MAX_PLAYERS
#define? MAX_PLAYERS? (100)
#endif
//
#include <fixes>
#include? ? <timerfix>
#include? ? <a_mysql>
#include? ? <foreach>
#include? ? <zcmd>
#include? ? <sscanf2>
#include? ? <MV_Youtube>
#include? ? <streamer>
#include? ? <callbacks>
#include? ? <mSelection>
#define AUTO_SETUP
#include? ? <gmtime> 

No, the problem is not with your game mode.
This function is such that the player freezes and the player can not move his camera and the player is not damaged.

It is the same in my game mode and I saw in other servers that it does not get damaged when the player is frozen.

I think the only way is to manually reduce the player armor and health when the player is frozen
  Reply
#9
The problem is with TogglePlayerControllable if you use this means that player cant control his character so he doesnt take damage thats how the function works
  Reply
#10
(2021-02-12, 09:44 PM)Radical Wrote:
(2021-02-12, 09:34 PM)RhaegarX Wrote:
(2021-02-12, 09:27 PM)Radical Wrote: I think in include weapon-config, this has been fixed.

But this include, changes the damaging to player algorithm a lot...



I will test this include, but in the case I wanted to solve this without resorting to includes.

Could some other include from my gamemode be causing the problem?



PHP Code:
#include? ? <a_samp>

#define FIXES_Single 1

#define FIXES_ServerVarMsg 0

// Redefini??es antes da Fixes

#if? ? ? defined MAX_PLAYERS

#undef? ? MAX_PLAYERS

#define? MAX_PLAYERS? (100)

#endif

//

#include <fixes>

#include? ? <timerfix>

#include? ? <a_mysql>

#include? ? <foreach>

#include? ? <zcmd>

#include? ? <sscanf2>

#include? ? <MV_Youtube>

#include? ? <streamer>

#include? ? <callbacks>

#include? ? <mSelection>

#define AUTO_SETUP

#include? ? <gmtime> 



No, the problem is not with your game mode.

This function is such that the player freezes and the player can not move his camera and the player is not damaged.



It is the same in my game mode and I saw in other servers that it does not get damaged when the player is frozen.



I think the only way is to manually reduce the player armor and health when the player is frozen





You're right! I tested it on other gamemodes and the same thing happens. Thank you for your help!
  Reply
#11
(2021-02-12, 09:53 PM)arber Wrote: The problem is with TogglePlayerControllable if you use this means that player cant control his character so he doesnt take damage thats how the function works





I realized that now. Thank you for your help!
  Reply
#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


Forum Jump: