Spawn on login - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawn on login (
/showthread.php?tid=228812)
Spawn on login -
bartje01 - 20.02.2011
Hey guys. I've got a little problem. I want that once you log in you'll spawn automaticly.
But it bugs. When I spawn I can walk but the camera doesn't move.
pawn Код:
if (dialogid == Login)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_RED, "Wrong password");
ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
}
else
{
logged[playerid] = 1;
PlayerInfo[playerid][adminlevel] = dini_Int(file, "adminlevel");
PlayerInfo[playerid][money] = dini_Int(file, "money");
PlayerInfo[playerid][score] = dini_Int(file, "score");
GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
SetPlayerScore(playerid, dini_Int(file, "score")-GetPlayerScore(playerid));
SendClientMessage(playerid,COLOR_RED, "Successfully logged in!");
SpawnPlayer(playerid);
}
}
return 0;
}
AW: Spawn on login -
!Phoenix! - 20.02.2011
Anything else used before than
pawn Код:
public OnGameModeInit()
{
AddPlayerClass();
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerCameraPos(); ()
SetPlayerCameraLookAt();
}
to change camera etc.?
Re: Spawn on login - rjjj - 20.02.2011
I think that it can solve your problem:
pawn Код:
if (dialogid == Login)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_RED, "Wrong password");
ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome back", "Pleas fill in your password below", "Login", "Leave");
}
else
{
logged[playerid] = 1;
PlayerInfo[playerid][adminlevel] = dini_Int(file, "adminlevel");
PlayerInfo[playerid][money] = dini_Int(file, "money");
PlayerInfo[playerid][score] = dini_Int(file, "score");
GivePlayerMoney(playerid, (dini_Int(file, "money")-GetPlayerMoney(playerid)));
SetPlayerScore(playerid, (dini_Int(file, "score")-GetPlayerScore(playerid)));
SendClientMessage(playerid,COLOR_RED, "Successfully logged in!");
TogglePlayerControllable(playerid, true);
SetCameraBehindPlayer(playerid);
SpawnPlayer(playerid);
return 1;
}
}
return 0;
}
I hope that i have helped
AW: Spawn on login -
!Phoenix! - 20.02.2011
@rjj: Btw: Please label your changes next time so that we don't have to use a program to detect them all.

(Did so - return 1 is correct, but the other two additions should be unnecessary)
Re: Spawn on login -
bartje01 - 20.02.2011
Thanks. But I fixed it with a timer