25.05.2015, 10:41
Alright, so I am trying to remove the spawn button and auto spawn the player after login, I have searched many threads, some of them had no effect and some had effect but not what exactly I want.
so, what I want is: When the player logs in he automatically spawns.
My codes for the automatic spawn and removing buttons:
The current problem is that it removes the spawn button and these thingys and it spawns the player, but it doesnt follow this
so, what I want is: When the player logs in he automatically spawns.
My codes for the automatic spawn and removing buttons:
pawn Код:
public OnPlayerRequestClass(playerid,classid)
{
SetSpawnInfo(playerid, TEAM_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
new string[120];
if(roundStarted == 0)
{
SetSpawnInfo(playerid, TEAM_HUMANS, 26, -2260.7219, 686.1232 , 49.2969, 0, 10, 1, 23, 200, 25, 200);
GetPlayerName( playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string),"{00FF51}[HUMAN BORN]{FFFFFF} A new human is now born, his name is {FFEA00}%s", pName);
SendClientMessageToAll(-1, string );
}
if(roundStarted != 0)
{
SetSpawnInfo(playerid, TEAM_ZOMBIES, 26, -2260.7219, 686.1232 , 49.2969, 0, 10, 1, 23, 200, 25, 200);
GetPlayerName( playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string),"{E00000}[ZOMBIE BORN]{FFFFFF} A new zombie is now born, his name is {E00000}%s", pName);
SendClientMessageToAll(-1, string );
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new query[128]; //We use this variable to format our query
GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
// - We use mysql_format instead of format because we can use an %e specifier. %e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
// - Formatting our query; SELECT `Password`, `ID` FROM `players` WHERE `Username`='%e' means we are selecting a Password and ID's column in the table that has player's name in Username column.
// - LIMIT 1; we only need 1 result to be shown
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
//lets execute the formatted query and when the execution is done, a callback OnAccountCheck will be called
//You can name the callback however you like
[B]TogglePlayerSpectating(playerid, 1)[/B];
return 1;
}
pawn Код:
public OnAccountLoad(playerid)
{
pInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
pInfo[playerid][VIP] = cache_get_field_content_int(0, "VIP"); //Above
pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");//Above
pInfo[playerid][posX] = cache_get_field_content_float(0, "PosX");//Above. Since player's position is a float, we use cache_get_field_content_float
pInfo[playerid][posY] = cache_get_field_content_float(0, "PosY");//Above
pInfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");//Above
GivePlayerMoney(playerid, pInfo[playerid][Money]);//Let's set their money
//For player's position, set it once they spawn(OnPlayerSpawn)
SendClientMessage(playerid, -1, "Successfully logged in"); //tell them that they have successfully logged in
TogglePlayerSpectating(playerid, 0);
SpawnPlayer(playerid);
return 1;
}
pawn Код:
if(roundStarted == 0)
{
SetSpawnInfo(playerid, TEAM_HUMANS, 26, -2260.7219, 686.1232 , 49.2969, 0, 10, 1, 23, 200, 25, 200);
GetPlayerName( playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string),"{00FF51}[HUMAN BORN]{FFFFFF} A new human is now born, his name is {FFEA00}%s", pName);
SendClientMessageToAll(-1, string );
}
if(roundStarted != 0)
{
SetSpawnInfo(playerid, TEAM_ZOMBIES, 26, -2260.7219, 686.1232 , 49.2969, 0, 10, 1, 23, 200, 25, 200);
GetPlayerName( playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string),"{E00000}[ZOMBIE BORN]{FFFFFF} A new zombie is now born, his name is {E00000}%s", pName);
SendClientMessageToAll(-1, string );
}