Spawn help?
#1

Hi. I'm having two issues. I'm sure I'm being blonde as always and it's a simple fix. Anyways; on my DIALOG_LOGIN (in my dialogresponse) I want the player to spawn at their saved location. I'm using SetSpawnInfo, however in the skin part I'm not quite sure what to put. Because I want it to be whatever skin the player selects. This is what my code looks like

Код:
	if(dialogid == DIALOG_LOGIN) //If dialog id is a login dialog
	{//then
	    if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
		if(response) //if they clicked the first button "Register"
		{//then
			new hashpass[129]; //Will create a new variable to hash his/her password
			WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
			if(!strcmp(hashpass, pInfo[playerid][Password], false)) //If they have insert their correct password
			{//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                TogglePlayerSpectating(playerid, false);
                SetTimerEx("UnsetFirstSpawn", 5000, false, "i", playerid); //We're using this for other purposes, to fix a bug in skin selection (OnPlayerRequestClass)
                Logged[ playerid ] = 1; //giving the 1 ("true") value to our variable "Logged"
				GivePlayerMoney(playerid,pInfo[playerid][Money]);//We will get their Money inside of his user's account and we will set it here
				SetSpawnInfo(playerid, 0 /*Because the player has no team*/, 0, pInfo[playerid][pPos_x], pInfo[playerid][pPos_y], pInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1); //Sets the player's spawn information
				SCM(playerid, COLOR_YELLOW, "You have successfully logged in. Please enjoy your stay!");
    		}
			else //If they've entered an incorrect password
			{//then
				ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back. This account is {FF0000}registered{FFFFFF}!. \nInsert your password to {0000FF}login{FFFFFF} to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                return 1;
			}
		}
	}
No I don't get any errors or anything.

However my next question or help needing is when I go into the server and login, I see next, previous and spawn however I don't see the images of the skins. I will post my gamemode on here if I need to but I'm just hoping someone will be able to tell me what's wrong straight away.

Thanks for your time and as always whom ever helps gets +1 Rep.
Reply
#2

When do you show the Login Dialog, is it OnPlayerConnect()? If it is, Then i would suggest you to set the players position after class selection and spawning. Instead of setting their spawn info.
Reply
#3

Here see SetSpawnInfo
PHP код:
    if(dialogid == DIALOG_LOGIN//If dialog id is a login dialog
    
{//then
        
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        
if(response//if they clicked the first button "Register"
        
{//then
            
new hashpass[129]; //Will create a new variable to hash his/her password
            
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            
if(!strcmp(hashpasspInfo[playerid][Password], false)) //If they have insert their correct password
            
{//then
                
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra true, .extra playerid);//We will load his account's data from user's path
                
TogglePlayerSpectating(playeridfalse);
                
SetTimerEx("UnsetFirstSpawn"5000false"i"playerid); //We're using this for other purposes, to fix a bug in skin selection (OnPlayerRequestClass)
                
Loggedplayerid ] = 1//giving the 1 ("true") value to our variable "Logged"
                
GivePlayerMoney(playerid,pInfo[playerid][Money]);//We will get their Money inside of his user's account and we will set it here
//                SetSpawnInfo(playerid, 0 /*Because the player has no team*/, 0, pInfo[playerid][pPos_x], pInfo[playerid][pPos_y], pInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1); //Sets the player's spawn information
                
SetSpawnInfo(playerid,0,GetPlayerSkin(playerid), pInfo[playerid][pPos_x], pInfo[playerid][pPos_y], pInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1); //Sets the player's spawn information
//                                        ^^^^^^^^^^^^^^^^^^^^^^^ it will get player's last skin and set it
                
SCM(playeridCOLOR_YELLOW"You have successfully logged in. Please enjoy your stay!");
            }
            else 
//If they've entered an incorrect password
            
{//then
                
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","{FFFFFF}Welcome back. This account is {FF0000}registered{FFFFFF}!. \nInsert your password to {0000FF}login{FFFFFF} to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                
return 1;
            }
        }
    } 
For second Question, Maybe your
PHP код:
public OnPlayerRequestClass(playeridclassid
function is empty.
Reply
#4

Yes I understand that. But rather than it being a 0 how do I change it so that it can be whatever the player has just selected?

PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;

Reply
#5

Have you added classes already?
PHP код:
public OnGameModeInit()
{
    
// Players can spawn with either the CJ skin (0) or The Truth skin (1).
    
AddPlayerClass(01958.331343.1215.36269.1526362815000); // CJ
    
AddPlayerClass(11958.331343.1215.36269.1526362815000); // The Truth
    
return 1;

Samp Wiki
https://sampwiki.blast.hk/wiki/AddPlayerClass
Reply
#6

I've added one class. AddPlayerClass(1,0,0,0,0,0,0,0,0,0,0); // and then I'm using mSelections for my spawn points.
Reply
#7

put the coordinates dude position must be on front of camera
Reply
#8

What do you mean?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)