2021-02-12, 08:18 PM
(This post was last modified: 2021-02-12, 08:19 PM by RhaegarX.)
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?
2021-02-12, 08:35 PM
(This post was last modified: 2021-02-12, 08:36 PM by Radical.)
Why do you freeze player?
You can apply an animation instead.
(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
I really tried to analyze everything in gamemode, but I can't solve this bug
2021-02-12, 09:27 PM
(This post was last modified: 2021-02-12, 09:30 PM by Radical.)
I think in include weapon-config, this has been fixed.
But this include, changes the damaging to player algorithm a lot...
(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>
2021-02-12, 09:35 PM
(This post was last modified: 2021-02-12, 09:43 PM by RhaegarX.)
(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
2021-02-12, 09:44 PM
(This post was last modified: 2021-02-12, 09:49 PM by Radical.)
(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
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
(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!
(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!
2021-02-23, 01:37 AM
(This post was last modified: 2021-02-23, 01:41 AM by RhaegarX.)
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(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.
|