Not spawning at hospital?
#1

So hey now my friend did something like when u die u spawn at a random position ( on bed ) in hospital and onplayerdeath he is assigning PlayerInfo[playerid][pHospital] = 1; and PlayerInfo[playerid][pHospitalTime] = 180; hospital time is the time he is gonna spend in hospital before he gets released i hope thats clear enough.
So now onplayerspawn i have this:
Код:
	if(PlayerInfo[playerid][pHospital] == 1)
        {
        new rand;
		rand = random(sizeof(gLeganjeMD));
		SetPlayerPos(playerid, gLeganjeMD[rand][0], gLeganjeMD[rand][1], gLeganjeMD[rand][2]);
		SetPlayerInterior(playerid, 0);
		PlayerInfo[playerid][pInt] = 0;
		SendClientMessage(playerid, C_RED, "{CFCB08}You have been moved to hospital cuz u ded m8.");
		SetPlayerSkin(playerid, 62);
		TogglePlayerControllable(playerid, 0);
		SetTimerEx("TeleportTimer", 2000, false, "d", playerid);
		bolnicatimer[playerid] = SetTimerEx("BolnicaTimerce", 1000, true, "d", playerid);
		SetTimerEx("BolnicaLeganjeTimer", 2010, false, "d", playerid);
		SetPlayerFacingAngle(playerid, 360);
		} 
if(PlayerInfo[playerid][pHospital] == 0)
{
... There i put some other stuff for normal spawn position( like textdraw shows for example)
}
Here are the timers:
Код:
forward TeleportTimer(playerid);
public TeleportTimer(playerid)
{
	TogglePlayerControllable(playerid, 1);
}

//------------------------------------------------------------------------------

forward BolnicaLeganjeTimer(playerid);
public BolnicaLeganjeTimer(playerid)
{
	ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
 	SetTimerEx("AnimacijaBolnica", 15000, false, "d", playerid);
}

//------------------------------------------------------------------------------

forward BolnicaTimerce(playerid);
public BolnicaTimerce(playerid)
{
    if(PlayerInfo[playerid][pHospital] == 1)
 	{
		if(PlayerInfo[playerid][pHospitalTime] >= 1)
		{
			PlayerInfo[playerid][pHospitalTime] -= 1;
			return 1;
		}
		else if(PlayerInfo[playerid][pHospitalTime] == 0)
		{
			new string[126];
			new string1[126];
			new medicbill = 100*PlayerInfo[playerid][pLevel];
			PlayerInfo[playerid][pHospitalTime] = 0;
			PlayerInfo[playerid][pHospital] = 0;
			SendClientMessage(playerid, C_GRAD1,"{739EFA}Doktor: {FFFFFF}You can go now m8 hospital isnt a place for u anymore.");
			OdzemiPari(playerid, medicbill);
			format(string1, sizeof(string1), "{739EFA}Doktor: {FFFFFF}Your bill is: $%d.",medicbill);
			SendClientMessage(playerid, C_BLCRVENA,string1);
			format(string, sizeof(string), "~g~YOU ARE READY TO GO!");
			GameTextForPlayer(playerid, string, 5000, 1);
			SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
			TogglePlayerControllable(playerid, 1);
			KillTimer(bolnicatimer[playerid]);
			SpawnPlayer( playerid  );
		}
 	}
	return 1;
}
Anything u found weird here ? I think everything is explained well so i hope u respond fast thanks
Reply
#2

Whats the problem?
Reply
#3

Quote:

SendClientMessage(playerid, C_RED, "{CFCB08}You have been moved to hospital cuz u ded m8.");

Lol....
Reply
#4

Well im not spawning at hospital obviously -> look at thread name fam im spawning at normal spawn if(PlayerInfo[playerid][pHospital] == 0) is being used on death too
Reply
#5

@Joron Dood its just a test script
Reply
#6

Change if(PlayerInfo[playerid][pHospital] == 0) to else if(PlayerInfo[playerid][pHospital] == 0), or return 1; under if(PlayerInfo[playerid][pHospital] == 1)
Reply
#7

Try:

Код:
if(PlayerInfo[playerid][pHospital] == 1) {
	new rand;
	rand = random(sizeof(gLeganjeMD));
	SetPlayerPos(playerid, gLeganjeMD[rand][0], gLeganjeMD[rand][1], gLeganjeMD[rand][2]);
	SetPlayerInterior(playerid, 0);
	PlayerInfo[playerid][pInt] = 0;
	SendClientMessage(playerid, C_RED, "{CFCB08}You have been moved to hospital cuz u ded m8.");
	SetPlayerSkin(playerid, 62);
	TogglePlayerControllable(playerid, 0);
	SetTimerEx("TeleportTimer", 2000, false, "d", playerid);
	bolnicatimer[playerid] = SetTimerEx("BolnicaTimerce", 1000, true, "d", playerid);
	SetTimerEx("BolnicaLeganjeTimer", 2010, false, "d", playerid);
	SetPlayerFacingAngle(playerid, 360);
} else {
// Your input :P
}
and

Код:
forward BolnicaTimerce(playerid);
public BolnicaTimerce(playerid)
{
    if(PlayerInfo[playerid][pHospital] == 1)
 	{
		if(PlayerInfo[playerid][pHospitalTime] >= 1) 
		{
			PlayerInfo[playerid][pHospitalTime] -= 1;
			return 1;
		} else {
			new string[128];
			new medicbill = 100*PlayerInfo[playerid][pLevel];
			PlayerInfo[playerid][pHospitalTime] = 0;
			PlayerInfo[playerid][pHospital] = 0;
			SendClientMessage(playerid, C_GRAD1,"{739EFA}Doktor: {FFFFFF}You can go now m8 hospital isnt a place for u anymore.");
			OdzemiPari(playerid, medicbill);
			format(string, sizeof(string), "{739EFA}Doktor: {FFFFFF}Your bill is: $%d.",medicbill);
			SendClientMessage(playerid, C_BLCRVENA,string);
			format(string, sizeof(string), "~g~YOU ARE READY TO GO!");
			GameTextForPlayer(playerid, string, 5000, 1);
			SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
			TogglePlayerControllable(playerid, 1);
			KillTimer(bolnicatimer[playerid]);
			SpawnPlayer( playerid  );
		}
 	}
	return 1;
}
Reply
#8

You basically copied what I've already done.

Changing the timer's if to an else makes no difference, so there's no need for it.
Reply
#9

done, still nothing, just spawning at that village on death and getting the welcome to the server message which is under else if(PlayerInfo[playerid][pHospital] == 0)
Reply
#10

Are you sure there's nothing else under OnPlayerSpawn?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)