SA-MP Forums Archive
Player dies and goes 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: Player dies and goes to hospital (/showthread.php?tid=634226)



Player dies and goes to hospital - NJSPKING - 15.05.2017

Hey so I need your guys help I'm working on a roleplay server and there is a problem with the death system. See normally when you get killed or dies your supposed to have the option to /service ems and wait till medical accepts you how ever instead of any of that happening. When you die you just spawn to the the hospital can anyone help me fix this please?!?!?!? I will provide anything you need thank you in advance


Re: Player dies and goes to hospital - Logic_ - 15.05.2017



Make your own code and if then you get any errors, show the code here and we'll report you the bugs and maybe also fix your errors. If you need someone to do that for you, find for a scripter then.


Re: Player dies and goes to hospital - NJSPKING - 15.05.2017

Quote:
Originally Posted by Logic_
Посмотреть сообщение


Make your own code and if then you get any errors, show the code here and we'll report you the bugs and maybe also fix your errors. If you need someone to do that for you, find for a scripter then.
I have already I just can't seem to figure out where I'm failing to where they keep being spawned to the hospital and not having the option /service ems


Re: Player dies and goes to hospital - iLearner - 15.05.2017

No idea, but it would be easier if returning 0 OnPlayerDeath would make player stuck at his death location (never tried)


Re: Player dies and goes to hospital - aoky - 15.05.2017

Quote:
Originally Posted by NJSPKING
Посмотреть сообщение
I will provide anything you need thank you in advance
Provide some code


Re: Player dies and goes to hospital - Hansrutger - 15.05.2017

Код:
enum {
	STATE_NONE,
	STATE_DEATH,
	STATE_HOSPITAL
};

new SomeState[MAX_PLAYER];


public OnPlayerDeath(playerid, killer, reason)
{
	if (SomeState[playerid] == STATE_NONE)
	{
		// spawn player at last given location
		SomeState[playerid] = STATE_DEATH;
	}
	else if (somestate[playerid][ == PLAYER_STATE_DEATH)
	{
		// spawn player in hospital
		SomeState[playreid] = STATE_HOSPITAL;
	}
	else if (SomeState[playerid] == STATE_HOSPITAL)
	{
		// if player dies while being in hospital, put them back in hospital and add timer, on timer add so that STATE_NONE is brought back to the player
		SomeState[playerid] = STATE_HOSPITAL;
	}
	return 1;
}

CMD:service(playeird, params)
{
	new option[15];
	if (sscanf(params, "s[15]", option))
	{
		// add all options
		return SendClientMessage(playerid, -1, "Use /service (option)");
	}
	
	if (!strcmp(option, "ems"))
	{
		// check here if player's state (not GetPlayerState) is STATE_DEATH
	}
	return 1;
}
Simple way of doing it, it has some intentional errors, fix them so you actually read the code and my comments.


Re: Player dies and goes to hospital - NJSPKING - 15.05.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
Provide some code
here you go sir

https://pastebin.com/rP82M5p5