SA-MP Forums Archive
Problem [+rep for helpers] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem [+rep for helpers] (/showthread.php?tid=499150)



Problem [+rep for helpers] - howtodo - 06.03.2014

I have a problem with the death system, when someone dying the doctor fill his hp and the system take him to the hospital directly.

Codes:

PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define col_grey 0xADADADFF
new pDied[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
// Checking for their variable..
    
if(pDied[playerid] == 1)
    {
    
// Spawning at ASGH in Los Santos...
        
pDied[playerid] = 0;
        
SetPlayerPos(playerid1177.8596, -1324.087614.0915);
                
// Message and money removal (using -400 at GivePlayerMoney to fine 500 as you automaticly lose $100 when you die).
        
SendClientMessage(playeridcol_grey"{639E4D}INFO:{ADADAD} You have just respawned and you lost $500!");
        
GivePlayerMoney(playerid, -400);
        }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    new 
Float:xFloat:yFloat:z;
    
// Resetting their position:
    
GetPlayerPos(playeridxyz);
    
SetPlayerPos(playeridxyz);
    
// Freezing them in death, aka not allowing them to respawn:
    
TogglePlayerControllable(playerid0);
    
ApplyAnimation(playerid"CRACK""crckdeth1"4.1011111);
    
// Informing them and activating timer:
    
SendClientMessage(playeridcol_grey"{639E4D}INFO:{ADADAD} You have been brutally wounded! If someone doesn't revive you soon, you will die!");
    
SetTimerEx("DeathTimer"3200false"i"playerid);
    return 
1;
}
forward DeathTimer(playerid);
public 
DeathTimer(playerid)
{
    
// As seen here: informing them and enabling variable:
    
SendClientMessage(playeridcol_grey"{639E4D}INFO:{ADADAD} Nobody managed to save you in time, you died!");
    
pDied[playerid] = 1;
    
// PlayerControllable to true...
    
TogglePlayerControllable(playerid1);
    return 
1;




Re: Problem [+rep for helpers] - XK - 06.03.2014

Because the time of the timer you have set is 3 seconds,so after 3 seconds he gets delivered to the hospital
And make it when the doctor fill his hp or accept the call from the wounded person,kill the timer there,so he wont die....
And to make the timer work good fix it, 1000 means 1 second and like that...


Re: Problem [+rep for helpers] - howtodo - 06.03.2014

can you change it for me ? Because I'm not sure what I'm doing.


Re: Problem [+rep for helpers] - XK - 06.03.2014

What is the time that you want it for the timer?in the minutes


Re: Problem [+rep for helpers] - howtodo - 06.03.2014

Take him five minutes until he dies.


Re: Problem [+rep for helpers] - howtodo - 06.03.2014

?


Re: Problem [+rep for helpers] - benjaminjones - 06.03.2014

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define col_grey 0xADADADFF

new pDied[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
// Checking for their variable..
    if(pDied[playerid] == 1)
    {
    // Spawning at ASGH in Los Santos...
        pDied[playerid] = 0;
        SetPlayerPos(playerid, 1177.8596, -1324.0876, 14.0915);
                // Message and money removal (using -400 at GivePlayerMoney to fine 500 as you automaticly lose $100 when you die).
        SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} You have just respawned and you lost $500!");
        GivePlayerMoney(playerid, -400);
        }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z;
    // Resetting their position:
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z);

    // Freezing them in death, aka not allowing them to respawn:
    TogglePlayerControllable(playerid, 0);
    ApplyAnimation(playerid, "CRACK", "crckdeth1", 4.1, 0, 1, 1, 1, 1, 1);

    // Informing them and activating timer:
    SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} You have been brutally wounded! If someone doesn't revive you soon, you will die!");
    SetTimerEx("DeathTimer", 30000, false, "i", playerid);
    return 1;
}

forward DeathTimer(playerid);
public DeathTimer(playerid)
{
    // As seen here: informing them and enabling variable:
    SendClientMessage(playerid, col_grey, "{639E4D}INFO:{ADADAD} Nobody managed to save you in time, you died!");
    pDied[playerid] = 1;

    // PlayerControllable to true...
    TogglePlayerControllable(playerid, 1);
    return 1;
}
Try it and tell me if it works


Re: Problem [+rep for helpers] - XK - 06.03.2014

lol you didnt add anything,you just edited the timer...


Re: Problem [+rep for helpers] - howtodo - 06.03.2014

OK, you give me the code ? and benjaminjones not working.


Re: Problem [+rep for helpers] - XK - 06.03.2014

i am making one for you,howtodo,be patient