time formatting & playerdeath
#1

hey sorry that I post alot of threads, I am just really intesnse to code this gamemode lol

How do I make a player freeze when he dies and make this timer to fill his hp? (roleplay mode)
like I set the camera on the hospital and wait to spawn the player for like 30 seconds filling his hp?

that's one..
2nd I made a time format, but it only calculates seconds and minutes, I want it to calculate hours and minutes
to implent a paycheck system..
this is my code:
Код:
new Hour, Minute, timestring[6];
new Text:timetext;
new Ztimer;


        Hour = 12;
	Minute = 00;
	Ztimer = SetTimer("timeupdate",1000,true);
	////////////////////////////////////////////////////////////////////////////////
	timetext = TextDrawCreate(557.761962, 406.208618, "00:00");
	TextDrawLetterSize(timetext, 0.314762, 1.066666);
	TextDrawAlignment(timetext, 1);
	TextDrawColor(timetext, -1);
	TextDrawSetShadow(timetext, 0);
	TextDrawSetOutline(timetext, 1);
	TextDrawBackgroundColor(timetext, 51);
	TextDrawFont(timetext, 1);
	TextDrawSetProportional(timetext, 1);

forward timeupdate();
public timeupdate()
{
	Minute += 01;
	if(Minute == 60 && Hour < 24) Hour += 01, Minute = 00;
	if(Hour == 24 && Minute == 00) Hour = 00, Minute = 00;
	format(timestring, sizeof(timestring), "%02d:%02d", Hour, Minute);
	TextDrawSetString(timetext,timestring);
	TextDrawShowForAll(timetext);
	TextDrawShowForAll(Text:Textdraw49);
	TextDrawShowForAll(Text:Textdraw50);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		SetPlayerTime(i,Hour,Minute);
	}
}
how do I fix this?

thanks alot!
Reply
#2

It's like when a player dies, set his camera at the hospital and start a timer. And follow the following steps in script.
- After player dies, set his camera at the hospital.
- Set the player's HP to 10.
- Set a timer of x seconds, if you are increasing it by 10 health per x seconds then make a timer for x * 9 and x seconds. ( You will need 2 timers cuz 1 timer will be used in removing the camera from hospital and spawning player and other for increasing it by 10.)
- In timer, get the player's current health in a array and then SetPlayerHealth(playerid,array + 10);
- Then after the timer that is x*9, spawn the player where you want him to.

There you go.
Reply
#3

Quote:
Originally Posted by JohnBlaze1971
Посмотреть сообщение
It's like when a player dies, set his camera at the hospital and start a timer. And follow the following steps in script.
- After player dies, set his camera at the hospital.
- Set the player's HP to 10.
- Set a timer of x seconds, if you are increasing it by 10 health per x seconds then make a timer for x * 9 and x seconds. ( You will need 2 timers cuz 1 timer will be used in removing the camera from hospital and spawning player and other for increasing it by 10.)
- In timer, get the player's current health in a array and then SetPlayerHealth(playerid,array + 10);
- Then after the timer that is x*9, spawn the player where you want him to.

There you go.
wut?
Reply
#4

I didnt compile / test this, but it should do what you wanted it to.

PHP код:
new bool:PendingHospital[MAX_PLAYERS];
new 
HospitalTimer[MAX_PLAYERS];
new 
HospitalHealth[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
PendingHospital[playerid] = false;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
PendingHospital[playerid] = true;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
KillTimer(HospitalTimer[playerid]); // incase someone logs out
}
public 
OnPlayerSpawn(playerid)
{
    if(
PendingHospital[playerid] == true)
    {
        
TogglePlayerControllable(playerid0);
        
SetPlayerPos(playeridx,y,z); // i recommend putting the player below the hospital if you want to be able to see your health rise, if not use TogglePlayerSpectating to remove the hud.
        
SetPlayerCameraPos(playerid,x,y,z);
        
        
SendClientMessage(playerid, -1"You've ended up in the hospital.."); // or something :)
        
HospitalHealth[playerid] = 10;
        
        
KillTimer(HospitalTimer[playerid]); // just incase its running due to lag or something similliar
        
HospitalTimer[playerid] = SetTimerEx("HospitalHealUpdate"1000true"i"i);
    }
    return 
1;
}
forward HospitalHealUpdate(playerid);
public 
HospitalHealUpdate(playerid)
{
    if(
HospitalHealth[playerid] < 100)
    {
        
HospitalHealth[playerid] += 10;
    }
    else
    {
        
TogglePlayerControllable(playerid1);
        
KillTimer(HospitalTimer[playerid]);
        
SetPlayerPos(playeridx,y,z); // wherever the door is / you want the player to spawn afterwards..
        
SetCameraBehindPlayer(playerid);
        
SendClientMessage(playerid, -1"You're now out of the hospital!");
    }
    return 
1;

Reply
#5

Quote:
Originally Posted by jbankss
Посмотреть сообщение
I didnt compile / test this, but it should do what you wanted it to.

PHP код:
new bool:PendingHospital[MAX_PLAYERS];
new 
HospitalTimer[MAX_PLAYERS];
new 
HospitalHealth[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
PendingHospital[playerid] = false;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
PendingHospital[playerid] = true;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
KillTimer(HospitalTimer[playerid]); // incase someone logs out
}
public 
OnPlayerSpawn(playerid)
{
    if(
PendingHospital[playerid] == true)
    {
        
TogglePlayerControllable(playerid0);
        
SetPlayerPos(playeridx,y,z); // i recommend putting the player below the hospital if you want to be able to see your health rise, if not use TogglePlayerSpectating to remove the hud.
        
SetPlayerCameraPos(playerid,x,y,z);
        
        
SendClientMessage(playerid, -1"You've ended up in the hospital.."); // or something :)
        
HospitalHealth[playerid] = 10;
        
        
KillTimer(HospitalTimer[playerid]); // just incase its running due to lag or something similliar
        
HospitalTimer[playerid] = SetTimerEx("HospitalHealUpdate"1000true"i"i);
    }
    return 
1;
}
forward HospitalHealUpdate(playerid);
public 
HospitalHealUpdate(playerid)
{
    if(
HospitalHealth[playerid] < 100)
    {
        
HospitalHealth[playerid] += 10;
    }
    else
    {
        
TogglePlayerControllable(playerid1);
        
KillTimer(HospitalTimer[playerid]);
        
SetPlayerPos(playeridx,y,z); // wherever the door is / you want the player to spawn afterwards..
        
SetCameraBehindPlayer(playerid);
        
SendClientMessage(playerid, -1"You're now out of the hospital!");
    }
    return 
1;

hey, thanks! but it compiles with 1 error here:
PHP код:
if(PendingHospital[playerid] == true)
    {
        
TogglePlayerControllable(playerid0);
        
SetPlayerPos(playerid2270.3811,-120.2083,20.1020)
        
SetPlayerCameraPos(playerid2291.3977,-94.1652,35.4931);
        
SetPlayerCameraLookAt(playerid2270.3811,-120.2083,27.1020);
        
SendClientMessage(playerid, -1"You've ended up in the hospital.."); 
        
HospitalHealth[playerid] = 10;
        
KillTimer(HospitalTimer[playerid]); 
        
HospitalTimer[playerid] = SetTimerEx("HospitalHealUpdate"1000true"i"i); // <<<<<<< undefined symbol i
    

Reply
#6

Код:
if(PendingHospital[playerid] == true) 
    { 
        TogglePlayerControllable(playerid, 0); 

        SetPlayerPos(playerid, 2270.3811,-120.2083,20.1020) 
        SetPlayerCameraPos(playerid, 2291.3977,-94.1652,35.4931); 
        SetPlayerCameraLookAt(playerid, 2270.3811,-120.2083,27.1020); 

        SendClientMessage(playerid, -1, "You've ended up in the hospital..");  

        HospitalHealth[playerid] = 10; 

        KillTimer(HospitalTimer[playerid]);  
        HospitalTimer[playerid] = SetTimerEx("HospitalHealUpdate", 1000, true, "i", playerid); 
    }
Reply
#7

Quote:
Originally Posted by ThatFag
Посмотреть сообщение
Код:
if(PendingHospital[playerid] == true) 
    { 
        TogglePlayerControllable(playerid, 0); 

        SetPlayerPos(playerid, 2270.3811,-120.2083,20.1020) 
        SetPlayerCameraPos(playerid, 2291.3977,-94.1652,35.4931); 
        SetPlayerCameraLookAt(playerid, 2270.3811,-120.2083,27.1020); 

        SendClientMessage(playerid, -1, "You've ended up in the hospital..");  

        HospitalHealth[playerid] = 10; 

        KillTimer(HospitalTimer[playerid]);  
        HospitalTimer[playerid] = SetTimerEx("HospitalHealUpdate", 1000, true, "i", playerid); 
    }
thx u rock repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)