spawn problems
#1

Hello, I am editing a gamemode and I want to change its player spawn location also the camera view when the register/log in box appears, I've tried to change some coordinates here

Код:
public OnPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, false);
	// Anti F4 Bug - Logging/Registering
	if(!PlayerInfo[playerid][pLoggedIn] && !IsPlayerNPC(playerid))
	{
		if(IsPlayerNPC(playerid)) return 1;
		SetPlayerPos(playerid, -2197.6575,-2376.3530,30.6250);// I changed this coordinate
		SetPlayerCameraPos(playerid, -2190.9714,-2374.7695,30.4688);// I changed this coordinate
		SetPlayerCameraLookAt(playerid, -2190.9714,-2374.7695,30.4688); // I changed this coordinate
	    SetSpawnInfo( playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	    new file[64];
Also changed coordinates at this lines

Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerVirtualWorld(playerid, 973942);
    if(IsPlayerNPC(playerid)) {SetPlayerVirtualWorld(playerid, 0); SpawnPlayer(playerid); return 1;}
    if(!PlayerInfo[playerid][pLoggedIn])
	{
		SetPlayerPos(playerid, -2197.6575,-2376.3530,30.6250);// I changed this coordinate
		SetPlayerCameraPos(playerid, -2190.9714,-2374.7695,30.4688);// I changed this coordinate
		SetPlayerCameraLookAt(playerid, -2190.9714,-2374.7695,30.4688);// I changed this coordinate
	    SetSpawnInfo(playerid, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0); // Without this you'll be kicked when you spawn. Set it to wherever you want.
        TogglePlayerSpectating(playerid, true);
        SetTimerEx("login_dialog", 100, 0, "i", playerid);
	    new file[64];
I changed all those coordinates, this coordinate -2197.6575,-2376.3530,30.6250 is where I want the player to spawn and this one -2190.9714,-2374.7695,30.4688 is where I want to point the camera.

Also I have to note everyone that the gamemode has a save position script, when I log out, my position is saved where I last disconnected. Do I need to edit something at public OnPlayerDisconnect(playerid, reason) or something ? this is how all the public OnPlayerDisconnect(playerid, reason) script looks.

Код:
public OnPlayerDisconnect(playerid, reason)
{
	// Bank Robbery
	if(BankRobber[playerid])
    {
	    new Rob = BankRobber[playerid]-1, string[128];
	    DisablePlayerCheckpoint(playerid);
		BankRobbersCount --;
		format(BankRobbers[Rob], MAX_PLAYER_NAME, "");
		DeliverMoney[playerid] = 0;
		//
		foreach(Player, i)
		{
		    if(BankRobber[i] || PlayerInfo[i][pFac] == 1)
		    {
				if(Rob == 0) TextDrawHideForPlayer(i, Textdraw1);
				else if(Rob == 1) TextDrawHideForPlayer(i, Textdraw2);
				else if(Rob == 2) TextDrawHideForPlayer(i, Textdraw3);
				else if(Rob == 3) TextDrawHideForPlayer(i, Textdraw4);
				else if(Rob == 4) TextDrawHideForPlayer(i, Textdraw5);
			}
		}
		format(string, sizeof(string), "** %s has disconnected and has failed the robbery. **", RPN(playerid));
		SendRobberyMessage(COLOR_LIGHTRED, string);
		SendCopMessage(COLOR_LIGHTRED, string);
		BankRobber[playerid] = 0;
		if(BankRobbersCount == 0)
		{
			TextDrawHideForAll(Textdraw0);
			TextDrawHideForAll(Textdraw1);
			TextDrawHideForAll(Textdraw2);
			TextDrawHideForAll(Textdraw3);
			TextDrawHideForAll(Textdraw4);
			TextDrawHideForAll(Textdraw5);
//			BankRobbery = 0;
			RobberyStarted = 0;
			format(string, sizeof(string), "** The bank robbery has ended, $%d were stolen and $%d were saved. **", TotalStolen*10000, (TotalRobbers*10000-(TotalStolen*10000)));
			SendClientMessageToAll(COLOR_YELLOW, string);
			TotalRobbers = 0;
			new copsonline;
			foreach(Player, i)
			{
			    if(IsACop(i)) copsonline++;
			}
			foreach(Player, i)
			{
			    if(IsACop(i))
			    {
					new Saved = (TotalRobbers*10000-(TotalStolen*10000));
					GiveDodMoney(i, Saved/copsonline);
					format(string, sizeof(string), "** You have received your cut from the saved money. ($%d)", Saved/copsonline);
					SendClientMessage(i, COLOR_LIME, string);
			    }
			}
		}
    }
    RemovePlayerAttachedObject(playerid, 0);
    //paintball
    if(PlayerPaintballing[playerid] == 1)
	{
	    ResetPlayerWeapons(playerid);
	    ResetDodWeapons(playerid);
	    SetPlayerPos(playerid,1310.1110,-1368.5656,13.517786);
	    for(new w = 0; w < 13; w++)
		{
		    GiveDodWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
		}
	}
	// Boxing
	new string[128];
	if(Boxing[playerid])
	{
        // Getting other boxer's ID
		new playerb = -1;
        foreach(Player, i)
        {
            if(Boxing[i] && i != playerid) playerb = i;
        }
        if(playerb != -1)
        {
            format(string, sizeof(string), "Boxing Ring: The boxing match has ended, %s has won the match.", RPN(playerb));
    		SendGymMessage(COLOR_WHITE, string);
            // Putting them out of the ring
            SetPlayerPos(playerb, 760.9759,4.7187,1000.7084);
            SetPlayerFacingAngle(playerb, 268.9407);
            SetPlayerPos(playerid, 760.9759,6.1794,1000.7093);
            SetPlayerFacingAngle(playerid, 268.9407);
            // Giving the winner extra skill point
            new oldj = strval(RPJL(playerb, JOB_BOXER));
            PlayerInfo[playerb][pJobSkill][JOB_BOXER] ++;
			new newj = strval(RPJL(playerb, JOB_BOXER));
		    if(oldj < newj)
			{
			    format(string, sizeof(string), "** Your Boxer level is now %d, you can now cause %d more damage. **", newj, (newj*2)-2);
				SendClientMessage(playerb, COLOR_YELLOW, string);
			}
			//
			SendClientMessage(playerb, COLOR_LIME, " You have won the boxing match.");
			SendClientMessage(playerid, COLOR_LIGHTRED, " You have lost the boxing match.");
			// Giving Bids
			new winner = pBoxer[playerb];
			foreach(Player, i)
			{
			    if(BidBoxer[i] == winner)
			    {
			        new percent, profit;
			        percent = (BidAmount[i]/BoxerBid[winner]) * 100;
			        profit = (percent * BoxerBid[pBoxer[playerid]]) / 100;
			        GiveDodMoney(i, BidAmount[i] + profit);
			        format(string, sizeof(string), " You have won $%d from bidding in the match, the money you bid has been returned as well.", profit);
			        SendClientMessage(i, COLOR_LIME, string);
			    }
				BidAmount[i] = 0;
				BidBoxer[i] = 0;
			}
			for(new w = 0; w < 13; w++)
			{
			    GiveDodWeapon(playerb, PlayerInfo[playerb][pWeapon][w], PlayerInfo[playerb][pWeaponAmmo][w]);
			}
        }
        for(new w = 0; w < 13; w++)
		{
		    GiveDodWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
		}
        // Resetting Values
		BoxingMatch = 0;
		Boxer[1] = -1;
		pBoxer[playerb] = 0;
		Boxer[2] = -1;
		pBoxer[playerid] = 0;
		Boxing[playerb] = 0;
		Boxing[playerid] = 0;
		BoxerBid[1] = 0;
		BoxerBid[2] = 0;
	    if(BoxTime)
	    {
			TogglePlayerControllable(playerb, 1);
	    	KillTimer(BoxTimer);
	    }
    }
	// The rest
	if(IsPlayerLoggedIn(playerid)) {SaveChar(playerid);}
	switch(reason)
	{
	    case 0: format(string, sizeof(string), "* %s has left the server. (Timeout)", RPN(playerid));
	    case 1: format(string, sizeof(string), "* %s has left the server. (Leaving)", RPN(playerid));
	    case 2: format(string, sizeof(string), "* %s has left the server. (Kicked/Banned)", RPN(playerid));
	}
	SendNearbyMessage(playerid, 10, string, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW);
	foreach(Player, i)
	{
	    if(Specid[i] == playerid)
	    {
	        Spec[i] = 0;
			Specid[i] = -1;
	    	TogglePlayerSpectating(i, 0);
			SetPlayerVirtualWorld(i, PlayerInfo[playerid][pVW]);
			SetPlayerInterior(i, PlayerInfo[playerid][pInt]);
			SetPlayerPos(i, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
			SendClientMessage(i, COLOR_WHITE, " You have stopped spectating players.");
	    }
	}
	// Clearing AD
	for(new i=0; i<MAX_ADS; i++)
	{
		if(strfind(AD[i], RPN(playerid)) != -1)
   		{
   		    format(AD[i], 128, "");
   		}
   	}
	// End of Clearing AD
	ClearChar(playerid);
	if(Planted[playerid] == 1)
	{
	    DestroyObject(C4[playerid]);
	    Bomb[playerid] = 0;
	    Planted[playerid] = 0;
	}
	return 1;
}
I know its a huge one, but I don't ask nobody to pass me the script edited and all done, I just ask to explain me what I need to change and what I am doing wrong even after the stock coordinates were changed with what I need now.




Thank You Very Much !
Reply
#2

Any help ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)