SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/07/2019, 04:20 PM   #1
Robson04
Big Clucker
 
Robson04's Avatar
 
Join Date: Aug 2018
Location: Poland
Posts: 96
Reputation: 0
Default SetPlayerTeam and OnPlayerTakeDamage problem

Hi everyone.
I had a problem of my manual system of health. I create a server-data health. If I remove health by the amount of call is isn't work.
What can I do?

My code;
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(pData[playerid][IsPlayerLogin] == false)
    {
        if(pData[playerid][IsInBW] == false)
        {
            new Float:damagehealth = AC_GetPlayerHealth(playerid) - amount;
            if(damagehealth <= 1)
            {
                GetPlayerPos(playerid, pData[playerid][LastPos][0], pData[playerid][LastPos][1], pData[playerid][LastPos][2]);
                GetPlayerFacingAngle(playerid, pData[playerid][LastPos][3]);
                SetPlayerBWState(playerid, weaponid);
            }
            else AC_SetPlayerHealth(playerid, damagehealth);
        }
    }
    return 1;
}

stock Float:AC_GetPlayerHealth(playerid)
    return pData[playerid][Health];

stock AC_SetPlayerHealth(playerid, Float:health)
{
    pData[playerid][Health] = health;
    SetPlayerHealth(playerid, pData[playerid][Health]);
    return 1;
}

If player login and has spawn;
pawn Code:
SetSpawnInfo(playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
Robson04 is offline   Reply With Quote
Old 25/07/2019, 06:50 AM   #2
N0FeaR
High-roller
 
N0FeaR's Avatar
 
Join Date: Nov 2011
Location: Sweden
Posts: 2,304
Reputation: 167
Default Re: SetPlayerTeam and OnPlayerTakeDamage problem

Do you still need help with this?
__________________
Here is my discord server https://discord.gg/ucVpDkJ
N0FeaR is offline   Reply With Quote
Old 25/07/2019, 07:29 AM   #3
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 821
Reputation: 125
Default Re: SetPlayerTeam and OnPlayerTakeDamage problem

Last time I checked setting their team does nothing for you with OnPlayerTakeDamage unless you're using EnableVehicleFriendlyFire()

For some reason, I've found that you need to set their team to NO_TEAM on connect then to a team ID on spawn for it to work properly.

Also make sure you're checking if issuerid is valid.
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerTakeDamage Problem Pro_Drifter Scripting Help 5 03/04/2015 10:18 AM
Problem with OnPlayerTakeDamage Syncro Scripting Help 11 05/05/2014 05:01 AM
OnPlayerTakeDamage problem UtkUguR Scripting Help 4 08/03/2012 09:12 PM
SetPlayerTeam Problem Gijs Help Archive 8 16/08/2009 07:27 PM
SetPlayerTeam problem Khelif Help Archive 3 27/07/2009 12:58 PM


All times are GMT. The time now is 04:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.