player spawn with no reason at 0.0.0
#1

Hello, i have some kinda bug in my script and i dont understand it, if player dies he should stay there and if they type /suicide then the player is spawned to hospital with timer and when the timer is over they spawn infront of the hospital but if you write /suicide it will just spawn at 0.0.0, help?

Код:
public OnPlayerSpawn(playerid)
{
    
	if(Logged[playerid] == 1)
	{
    if(Hospitalized[playerid] == 1)
	{
 	SetPlayerToTeamColor(playerid);
 	TogglePlayerControllable(playerid,false);
 	SetPlayerHealth(playerid,1.0);
 	SetPlayerPos(playerid,-2635.5378,648.4147,52.285);
 	SetPlayerInterior(playerid,0);
 	TogglePlayerControllable(playerid, 0);
 	IsDead[playerid] = 0;
  	SetPlayerColor(playerid,COLOR_WHITE);
	GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~You need to rest now, please wait.",8000,3);
	SetTimerEx("AfterSpawnHos", 10000, false, "i", playerid);
	ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 1, 1, 1, 1);
  	new RandomVW;
	RandomVW = random(2);
 	switch(RandomVW)
 	{
  	case 0:
  	{
  	SetPlayerVirtualWorld(playerid,1);
  	}
    case 1:
  	{
  	SetPlayerVirtualWorld(playerid,2);
  	}
	}
	return 1;
	}
	
 	if(PlayerInfo[playerid][pJailed] == 1)
	{
 	SetPlayerInterior(playerid, 10);
  	SetPlayerVirtualWorld(playerid,20);
   	SetPlayerPos(playerid,227.2460,109.7719,999.0156);
    SetPlayerColor(playerid,COLOR_WHITE);
	PlayerCuffed[playerid] = 0;
	TextDrawShowForPlayer(playerid, MissionTL[playerid]);
 	return 1;
	}

	if(PlayerInfo[playerid][pTutorial] == 1)
	{
	new string2[512];
	tutorialstage[playerid] = 1;
	SetPlayerHealth(playerid,100);
	SetPlayerPos(playerid,-2000.9891,114.5674,36.8061);
	SetPlayerCameraPos(playerid,-2000.9891,114.5674,34.8061);//trainstation
	SetPlayerCameraLookAt(playerid,-1983.2843,137.8904,27.6875);
	format(string2,sizeof(string2),"This is the train station, your first spawn place.");
	TextDrawSetString(Textdraw98[playerid],string2);
	TextDrawShowForPlayer(playerid,Textdraw98[playerid]);
	TextDrawShowForPlayer(playerid,Textdraw97[playerid]);
	TogglePlayerControllable(playerid,0);
	SetPlayerVirtualWorld(playerid,3);
	return 1;
	}


	if(FirstSpawn[playerid] == 1)
	{
	SetPlayerPos(playerid, -1961.9011,138.1674,27.6940);
	FirstSpawn[playerid] = 0;
	return 1;
	}



	if(OnFloor[playerid] == 1)
	{
	SendClientMessage(playerid,COLOR_RED,"You are Dying, you need to be revived or you can /suicide");
	SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
	ApplyAnimation(playerid,"CRACK","crckdeth2",4.0,0,0,0,1,1);
	ApplyAnimation(playerid,"CRACK","crckdeth2",4.0,0,0,0,1,1);
	TogglePlayerControllable(playerid,0);
	ApplyAnimation(playerid,"CRACK","crckdeth2",4.0,0,0,0,1,1);
	return 1;
	}
	Managing[playerid] = -255;

	if(JustLogged[playerid] == 1)
	{
	if(PlayerInfo[playerid][pPos_x] == 0 && PlayerInfo[playerid][pPos_y] == 0)
  	{
  	SetPlayerPos(playerid, -1983.2843,137.8904,27.6875);
	}
  	else
	{
	SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
 	}
	SetTimerEx("LoadObjects",2000,0,"i",playerid);
	TogglePlayerControllable(playerid,0);
	SendClientMessage(playerid,COLOR_GREEN,"Loading Objects...");
	SetTimerEx("WeightTimer", 600000, true, "i", playerid);
	JustLogged[playerid] = 0;
	
	if(PlayerInfo[playerid][OnSteroids] > 0)
	{
	SetTimerEx("SteroidsTimer", 60000, false, "i", playerid);
	}
	
	SetPlayerFightingStyle(playerid, PlayerInfo[playerid][pFightingStyle]);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetPlayerColor(playerid,COLOR_WHITE);
	CP[playerid] = -1;
	Step[playerid] = 0;
	InPickUp[playerid] = 0;
	PlayerCuffed[playerid] = 0;
	RacketIDMenu[playerid] = 0;
	ContinueTaser[playerid] = 0;
	TextDrawShowForPlayer(playerid,ShadowsRandom);
	}
	}
    return 1;
}
onplayerdeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(Hospitalized[playerid] == 0)
	{
	OnFloor[playerid] = 1;
	}
	else
	{
	OnFloor[playerid] = 0;
	}
	
 	new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    DropGun(playerid, GetPlayerWeapon(playerid),GetPlayerAmmo(playerid),X,Y,Z,GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));

	
	if(GetPVarInt(playerid,"YEAH") == 1)
	{
    	DisablePlayerCheckpoint(playerid);
    	DestroyObject(GPSObject[playerid]);
    	SetPVarInt(playerid,"YEAH",0);
    	DeletePVar(playerid,"Spongebob");
    	DeletePVar(playerid,"Mario");
    	DeletePVar(playerid,"SpiderPig");
    	DeletePVar(playerid,"FAIL");
    	TextDrawHideForPlayer(playerid, GPSTD);
    	ActiveCP[playerid] = 0;
	}
	if(WearingGloves[killerid] == 1)
	{
	WoreGloves[killerid] = 1;
	}
	
	
	TextDrawHideForPlayer(playerid,Text1);
	TextDrawHideForPlayer(playerid,Text2);
	TextDrawHideForPlayer(playerid,Background);
	TextDrawHideForPlayer(playerid,ShadInfoBox[playerid]);
	TextDrawHideForPlayer(playerid,BackgroundOverview);
	TextDrawHideForPlayer(playerid,InformationsOverview);
	TextDrawHideForPlayer(playerid,BuyText);
	TextDrawHideForPlayer(playerid,CancelText);
	TextDrawHideForPlayer(playerid,BackgroundNotEnough);
	TextDrawHideForPlayer(playerid,TextNotEnough1);
	TextDrawHideForPlayer(playerid,TextNotEnough2);
	TextDrawHideForPlayer(playerid,BackgroundGunBought);
	TextDrawHideForPlayer(playerid,TextGunBought);
 	TextDrawHideForPlayer(playerid, Blood1), TextDrawHideForPlayer(playerid, Blood2), TextDrawHideForPlayer(playerid, Blood3), TextDrawHideForPlayer(playerid, Blood4);
	PlayerLookAtGun[playerid] = 0;
	Cracked[playerid] = 0;
	Managing[playerid] = -255;
	DamMade[playerid] = 0;
	Milking[playerid] = 0;
	UsingSafe[playerid] = -255;
	PlayerInfo[killerid][pKills] += 1;
	new string[128];
	new killername[MAX_PLAYER_NAME];
	if(Step[playerid] > 1)
	{
	    SendClientMessage(playerid, COLOR_RED, "You've failed your driving test.");
	}
 	if(PlayerInfo[killerid][OnMission] == 1)
	{
	if(PlayerInfo[killerid][MissionNr] == 1)
	{
	if(PlayerInfo[playerid][Member] == PlayerInfo[killerid][MissionID])
	{
	GivePlayerAchievement(killerid, Ach_Killingmission, 1);
	SavePlayerAchievements(playerid);
	PlayerInfo[playerid][OnMission] = 0;
	PlayerInfo[playerid][MissionNr] = 0;
	PlayerInfo[playerid][MissionID] = 0;
	PlayerInfo[playerid][MissionStep] = 0;
	}
	}
	}
	if(strcmp(PlayerInfo[killerid][pTaunt],"None", true ) == 0 )
	{
       format(string, sizeof(string), "%s Shouts: %s!!", killername, PlayerInfo[killerid][pTaunt]);
       ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
   	}
   	
    return 1;
}
(PS the Taunt is bugged too if someone knows whats wrong then please tell me :P it just shouts: none!!

/suicide
Код:
CMD:suicide(playerid,params[])
{
if(OnFloor[playerid] == 1)
{
new string[128];
format(string, sizeof(string), "* %s eyes closes slowly and their pulse stop.", GetPlayerNameEx(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
FirstTime[playerid] = 0;
OnFloor[playerid] = 0;
IsDead[playerid] = 1;
Hospitalized[playerid] = 1;
PlayerInfo[playerid][pDeaths] += 1;
GetPlayerPos(playerid, Xa[playerid], Ya[playerid], Za[playerid]);
O[playerid] = CreateDynamicObject(3092, Xa[playerid], Ya[playerid], Za[playerid],0, 0, 274);
SetPlayerHealth(playerid,0);
SpawnPlayer(playerid);
SaveAccountStats(playerid);
}
return 1;
}
thank you for your help
Reply
#2

Everything happens for a reason when you're talking about computers. Things don't happen randomly.
Reply
#3

Yeah but can you see the reason in here?
Reply
#4

Do you ever use SetSpawnInfo? I would search around for that or add that to your codes above (/suicide and onplayerdeath) to the position/spawn you want when the player to respawn.
Reply
#5

i tried it but it wont start to read the code from onplayerspawn
that part
Код:
    if(Hospitalized[playerid] == 1)
	{
 	SetPlayerToTeamColor(playerid);
 	TogglePlayerControllable(playerid,false);
 	SetPlayerHealth(playerid,1.0);
 	SetPlayerPos(playerid,-2635.5378,648.4147,52.285);
 	SetPlayerInterior(playerid,0);
 	TogglePlayerControllable(playerid, 0);
 	IsDead[playerid] = 0;
  	SetPlayerColor(playerid,COLOR_WHITE);
	GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~You need to rest now, please wait.",8000,3);
	SetTimerEx("AfterSpawnHos", 10000, false, "i", playerid);
	ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 1, 1, 1, 1);
  	new RandomVW;
	RandomVW = random(2);
 	switch(RandomVW)
 	{
  	case 0:
  	{
  	SetPlayerVirtualWorld(playerid,1);
  	}
    case 1:
  	{
  	SetPlayerVirtualWorld(playerid,2);
  	}
	}
can anyone help me?thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)