ID 0 get sent to hospital
#1

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]++;
Reply
#2

update the includes that you use, that could be it!
Reply
#3

Post full code?
Reply
#4

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

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;
}
Reply
#6

Show onplayerdeath?
Reply
#7

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

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);
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)