Posts: 10
Threads: 3
Joined: Apr 2018
Reputation:
0
Hello,
My name is Colween and im new here.
i have a big problem with my script (Hospital Spawn)
my codes
// OnPlayerSpawn
{
SetPlayerPos( p id etc )
return 1;
}
// Onplayerdeath
setplayerpos(p id etc)
And it respawn my player at OnPlayerSpawn's pos any solution?
Posts: 3,324
Threads: 96
Joined: Sep 2013
Not sure exactly what your issue is... but...
OnPlayerSpawn is called when a player is set to spawn, before actually spawning. Honestly setting the player's position there isn't the best option, a more proper way to avoid very minor weird things would be getting used to using SetSpawnInfo BEFORE the player is sent to OnPlayerSpawn.
Using SetPlayerPos will indeed set the player's position, the player will be where you tell them to be.
Setting the position in OnPlayerDeath is probably not going to do much for you for what you are doing, it's called when the player is pronounced dead. Using SetPlayerPos here will not set the player's position because the player is going to respawn and be sent to their spawn position (assigned by AddPlayerClass or SetSpawnInfo).
Basically, when OnPlayerSpawn is called, internally your player is going to be sent to the position set by AddPlayerClass or SetSpawnInfo. You are setting the player's position in OnPlayerSpawn (as most people do unfortunately, including me even), which will be after they are sent to the other position. Setting the position in OnPlayerDeath isn't going to do much.
Posts: 10
Threads: 3
Joined: Apr 2018
Reputation:
0
then? what i have to do now?
Posts: 21
Threads: 2
Joined: Feb 2019
Reputation:
0
Try using this.
SetSpawnInfo();
Posts: 3,324
Threads: 96
Joined: Sep 2013
Quote:
Originally Posted by ColweeN
then? what i have to do now?
|
We don't know what you have to do. You didn't explain anything and you didn't even give us real code. WHAT are you trying to do? What is your goal and what the hell is the problem?
Posts: 10
Threads: 3
Joined: Apr 2018
Reputation:
0
Hello,
@Crayder here are my codes.
public OnPlayerSpawn(playerid)
{
SetPlayerPos(playerid, 2616.5447,2453.2605,14.8672);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerPos(playerid, 10.2967,148.8675,999.0613);
SetPlayerHealth(playerid, 100);
GivePlayerMoney(playerid, -500);
SendClientMessage(playerid, -1,"DOCTOR: You have paid your medical bill.");
return 1;
}