Injury system with weapon-config
#1

I am using the weapon-config plugin and I am working on an 'injury system'. The idea is that if you die, you respawn at the location where you died and you're forced into an animation. This only happens if you are not injured already.

Right now I've got the following code:

In here I store the coordinates where the player died:


PHP код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    <
blabla>
    
    new 
Float:hp;
    
GetPlayerHealth(playeridhp);
    if(
hp amount <= 0.0)
    {
        
SendClientMessageToAll(COLOR_WHITE"New HP = less than 0");
        
GetPlayerPos(playeridpInfo[playerid][pInjuredX], pInfo[playerid][pInjuredY], pInfo[playerid][pInjuredZ]);
        new 
str[128];
        
format(strsizeof(str), "Injured coords; %f, %f, %f"pInfo[playerid][pInjuredX], pInfo[playerid][pInjuredY], pInfo[playerid][pInjuredZ]);
        
SendClientMessageToAll(COLOR_WHITEstr);
    }
    
    return 
1;

This part is supposed to be respawning the player in the same location where he died:

PHP код:
public OnPlayerPrepareDeath(playeridanimlib[32], animname[32], &anim_lock, &respawn_time)
{
    
respawn_time 1;
    
SendClientMessageToAll(COLOR_WHITE"OnPlayerPrepareDeath called");
    return 
1;
}
public 
OnPlayerDeathFinished(playeridbool:cancelable)
{
    if(
pInfo[playerid][pInjured] == 0)
    {
        
SendClientMessageToAll(COLOR_WHITE"Injured = 0");
        
pInfo[playerid][pInjured] = 1;
        
pInfo[playerid][pInjuredRefreshTimer] = 5;
        
SetPlayerPos(playeridpInfo[playerid][pInjuredX], pInfo[playerid][pInjuredY], pInfo[playerid][pInjuredZ]);
        
SetPlayerSkin(playeridpInfo[playerid][pSkin]);
        new 
str[128];
        
format(strsizeof(str), "Injured coords (OnPlayerDeath); %f, %f, %f"pInfo[playerid][pInjuredX], pInfo[playerid][pInjuredY], pInfo[playerid][pInjuredZ]);
        
SendClientMessageToAll(COLOR_WHITEstr);
        
pInfo[playerid][pHealth] = 100.0;
        
pInfo[playerid][pArmor] = 0.0;
        
SetPlayerHealth(playeridpInfo[playerid][pHealth]);
        
SetPlayerArmour(playeridpInfo[playerid][pArmor]);
        
PlayDeathAnimation(playerid);
    }
    else
    {
        
SendClientMessageToAll(COLOR_WHITE"Injured != 0");
        
pInfo[playerid][pInjured] = 0;
        
pInfo[playerid][pInjuredRefreshTimer] = 0;
        
pInfo[playerid][pHealth] = 50.0;
        
pInfo[playerid][pArmor] = 0.0;
        
SetPlayerHealth(playeridpInfo[playerid][pHealth]);
        
SetPlayerArmour(playeridpInfo[playerid][pArmor]);
    }
    return 
1;


Instead of moving the player to the stored coordinates he is being teleported to Blueberry (coordinates 0.0, 0.0, 0.0). I have tried using the OnPlayerDeath callback too but I can't seem to get it working.

Does anyone have an idea of what I am doing wrong?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)