Spawn help? -
Tass007 - 15.07.2016
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.
Re: Spawn help? -
DarkSkull - 15.07.2016
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.
Re: Spawn help? -
gurmani11 - 15.07.2016
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(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
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(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;
}
}
}
For second Question, Maybe your
PHP код:
public OnPlayerRequestClass(playerid, classid)
function is empty.
Re: Spawn help? -
Tass007 - 15.07.2016
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(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
Re: Spawn help? -
gurmani11 - 15.07.2016
Have you added classes already?
PHP код:
public OnGameModeInit()
{
// Players can spawn with either the CJ skin (0) or The Truth skin (1).
AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0); // CJ
AddPlayerClass(1, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0); // The Truth
return 1;
}
Samp Wiki
https://sampwiki.blast.hk/wiki/AddPlayerClass
Re: Spawn help? -
Tass007 - 15.07.2016
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.
Re: Spawn help? -
gurmani11 - 15.07.2016
put the coordinates dude position must be on front of camera
Re: Spawn help? -
Tass007 - 15.07.2016
What do you mean?