SA-MP Forums Archive
ID 0 get sent to hospital - 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: ID 0 get sent to hospital (/showthread.php?tid=374056)



ID 0 get sent to hospital - Why - 01.09.2012

Hello. I am scripting a hospital system for my roleplay server, however id 0 get sent to hospital instead of the player that died.

pawn Code:
SendClientMessage(playerid, -1, "The medics failed to revive you or you body was moved causing you to die.");
        RecoverHospital(playerid);
        SetTimer("RecoverHospital2", 6000, false);
        SetTimer("RecoverHospital3", 8000, false);
        SetTimer("RecoverHospital4", 10000, false);
        SetTimer("RecoverHospital5", 12000, false);
        SetTimer("RecoverHospital6", 14000, false);
        SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1178, -1324, 8.11, 0, 0, 0, 0, 0, 0, 0);
        SetPVarInt(playerid, "Injured", 0);
        SetPVarInt(playerid, "Recovering", 1);
        SpawnPlayer(playerid);
        PlayerInfo[killerid][pKills]++;
        PlayerInfo[playerid][pDeaths]++;



Re: ID 0 get sent to hospital - [FR]Fratzica - 01.09.2012

update the includes that you use, that could be it!


Re: ID 0 get sent to hospital - Admigo - 01.09.2012

Post full code?


Re: ID 0 get sent to hospital - Kirollos - 01.09.2012

i've found the problem , but you need to post full code to let us fix it -.-


Re: ID 0 get sent to hospital - Why - 01.09.2012

pawn Code:
forward RecoverHospital(playerid);
public RecoverHospital(playerid)
{new str[56];
    format(str, 56, "Recovering id %i from hospital (1/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SendClientMessage(playerid, -1, "You have to recover health at the hospital.");
    SetPlayerHealth(playerid, 50);
}
forward RecoverHospital2(playerid);
public RecoverHospital2(playerid)
{new str[56];
    format(str, 56, "Recovering id %i from hospital (2/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SetPlayerHealth(playerid, 60);
}
forward RecoverHospital3(playerid);
public RecoverHospital3(playerid)
{new str[56];
    format(str, 56, "Recovering id %i from hospital (3/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SetPlayerHealth(playerid, 65);
}
forward RecoverHospital4(playerid);
public RecoverHospital4(playerid)
{new str[56];
    format(str, 56, "Recovering id %i from hospital (4/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SetPlayerHealth(playerid, 70);
}
forward RecoverHospital5(playerid);
public RecoverHospital5(playerid)
{   new str[56];
    format(str, 56, "Recovering id %i from hospital (5/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SetPlayerHealth(playerid, 75);
}
forward RecoverHospital6(playerid);
public RecoverHospital6(playerid)
{
    new str[56];
    format(str, 56, "Recovered and spawned id %i from hospital (6/6)..", playerid);
    SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
    SetPlayerPos(playerid, 1178.4980,-1323.4543,14.1230);
    SetPlayerFacingAngle(playerid, 271.3259);
    SetPlayerHealth(playerid, 80);
    TogglePlayerControllable(playerid, 1);
    SetCameraBehindPlayer(playerid);
    SetPVarInt(playerid, "Recovering", 0);
    SendClientMessage(playerid, COLOR_LIGHTRED, "Hospital: The hospital bill came to $200. Buy an insurance for a cheaper bill.");
    PlayerInfo[playerid][pCash] -= 100;
}
Ignore the recovering thingy. Thats just a debug I made to try to identify the problem.

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPVarInt(playerid, "Injured") != 1)
    {
        new Float:ipx, Float:ipy, Float:ipz;
        SetPVarInt(playerid, "Injured", 1);
        PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
        PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
        GetPlayerPos(playerid, ipx, ipy, ipz);
        SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], ipx, ipy, ipz, 0, 0, 0, 0, 0, 0, 0);
//      SendClientMessage(playerid, -1, "Entering injured state.");
    }
    else
    {
        new str[56];
        SendClientMessage(playerid, -1, "The medics failed to revive you or you body was moved causing you to die.");
        format(str, 56, "Sending id %i to hospital", playerid);
        SendClientMessageToAdmins(COLOR_LIGHTRED, str, 1);
        RecoverHospital(playerid);
        SetTimer("RecoverHospital2", 6000, false);
        SetTimer("RecoverHospital3", 8000, false);
        SetTimer("RecoverHospital4", 10000, false);
        SetTimer("RecoverHospital5", 12000, false);
        SetTimer("RecoverHospital6", 14000, false);
        SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1178, -1324, 8.11, 0, 0, 0, 0, 0, 0, 0);
        SetPVarInt(playerid, "Injured", 0);
        SetPVarInt(playerid, "Recovering", 1);
        SpawnPlayer(playerid);
        PlayerInfo[killerid][pKills]++;
        PlayerInfo[playerid][pDeaths]++;
        return 1;
    }
    return 1;
}



Re: ID 0 get sent to hospital - Admigo - 01.09.2012

Show onplayerdeath?


Re: ID 0 get sent to hospital - Why - 01.09.2012

Quote:
Originally Posted by admigo
View Post
Show onplayerdeath?
look at the post above


Re: ID 0 get sent to hospital - Kirollos - 01.09.2012

at onplayerdeath

replace
pawn Code:
SetTimer("RecoverHospital2", 6000, false);
SetTimer("RecoverHospital3", 8000, false);
SetTimer("RecoverHospital4", 10000, false);
SetTimer("RecoverHospital5", 12000, false);
SetTimer("RecoverHospital6", 14000, false);
to
pawn Code:
SetTimerEx("RecoverHospital2", 6000, false, "i", playerid);
SetTimerEx("RecoverHospital3", 8000, false, "i", playerid);
SetTimerEx("RecoverHospital4", 10000, false, "i", playerid);
SetTimerEx("RecoverHospital5", 12000, false, "i", playerid);
SetTimerEx("RecoverHospital6", 14000, false, "i", playerid);



Re: ID 0 get sent to hospital - Why - 01.09.2012

Quote:
Originally Posted by kirollos
View Post
at onplayerdeath

replace
pawn Code:
SetTimer("RecoverHospital2", 6000, false);
SetTimer("RecoverHospital3", 8000, false);
SetTimer("RecoverHospital4", 10000, false);
SetTimer("RecoverHospital5", 12000, false);
SetTimer("RecoverHospital6", 14000, false);
to
pawn Code:
SetTimerEx("RecoverHospital2", 6000, false, "i", playerid);
SetTimerEx("RecoverHospital3", 8000, false, "i", playerid);
SetTimerEx("RecoverHospital4", 10000, false, "i", playerid);
SetTimerEx("RecoverHospital5", 12000, false, "i", playerid);
SetTimerEx("RecoverHospital6", 14000, false, "i", playerid);
Thank you very much. Could you by any chance explain it so that in the future when I want to make such timers, I don't do the same mistake.


Re: ID 0 get sent to hospital - Admigo - 01.09.2012

Quote:
Originally Posted by Why
View Post
Thank you very much. Could you by any chance explain it so that in the future when I want to make such timers, I don't do the same mistake.
If you have skype i can help you. My server only use one timer:P