PDA

View Full Version : SpawnPlayer


HondaCBR
28/12/2011, 01:26 AM
Hello, I made a script so you get given a skin and you spawn straight away, but the problem is that you spawn and cant move coz there are the class slection options below left and right arrow bla bla.... any ideas?

Log in.

if(dialogid == LOGOWANIE)
{
if(response)
{
if(strlen(inputtext)>=5 && strlen(inputtext)<=20)
{
new tmppass[64];
format(tmppass, sizeof(tmppass), inputtext);
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
SetCameraBehindPlayer(playerid);
}
else if(strlen(inputtext)<=0)
{
ShowPlayerDialog(playerid, LOGOWANIE, DIALOG_STYLE_PASSWORD, "Logowanie", "{ED2F15} Nieprawidlowe Haslo!, Podaj haslo dla tej postaci:", "Ok", "Anuluj");
}
else
{
Kick(playerid);
}
}
else
{
Kick(playerid);
}
}

Logging in callback.
public OnPlayerLogin(playerid,password[])
{
// new tmp2[256];
new string2[64];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "Konta/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pReg] = strval( val ); }
}
fclose(UserFile);
}
else
{
ShowPlayerDialog(playerid, LOGOWANIE, DIALOG_STYLE_PASSWORD, "Logowanie", "{ED2F15} Nieprawidlowe Haslo!, Podaj haslo dla tej postaci:", "Ok", "Anuluj");
fclose(UserFile);
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 4) { Kick(playerid); }
return 1;
}
// PlayerInfo[playerid][pAdjustable] = 0;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
CurrentMoney[playerid] = PlayerInfo[playerid][pCash];
if(PlayerInfo[playerid][pReg] == 0)
{
PlayerInfo[playerid][pLevel] = 1;
PlayerInfo[playerid][pReg] = 1;
GivePlayerMoney(playerid, 50);
}
if(PlayerInfo[playerid][pLevel] == -999) //autoban
{
Ban(playerid);
}
if(PlayerInfo[playerid][pLevel] == -1000) //autoban
{
Kick(playerid);
}
printf("%s zalogowal sie.",playername2);
gPlayerLogged[playerid] = 1;
SetPlayerSkin(playerid, 289);//fornow
SetPlayerSpawn(playerid);
SpawnPlayer(playerid);
}
GetPlayerName(playerid,string2,sizeof(string2));
return 1;
}

Setting spawn
public SetPlayerSpawn(playerid)
{
if(IsPlayerConnected(playerid))
{
SetPlayerInterior(playerid,0);
new string[123], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new randuid = 10000 + random(98767);
format(string, sizeof(string), "Witaj %s (ID: %d) [UID: %d]",playername,playerid,randuid);
ClearChatbox(playerid, 12);
SendClientMessage(playerid, COLOR_RED, string);
ResetPlayerWeapons(playerid);
new rand = random(sizeof(gRandomPlayerSpawns));
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
SetPlayerFacingAngle(playerid, 97.0238);
return 1;
}
return 1;
}

Steven82
28/12/2011, 01:31 AM
You need to use SetSpawnInfo (http://wiki.sa-mp.com/wiki/SetSpawnInfo) somewhere in your SetPlayerSpawn function.

HondaCBR
28/12/2011, 01:40 AM
Could I use: SetSpawnInfo(playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
right at the top of SetPlayerSpawn, and then everything will get configured from there?

MP2
28/12/2011, 01:42 AM
It depends if you use SetPlayerPos under OnPlayerSpawn or if you use the classes spawns (set with AddPlayerClass). If you use SetPlayerPos for spawning, that will be fine. If you use the AddPlayerClass spawns, they will spawn at 0, 0, 0.