#include <a_samp>
main() { }
public OnGameModeInit() {
return true;
}
public OnGameModeExit() {
return true;
}
public OnPlayerConnect(playerid) {
Player_SetSpawnInfo(playerid);
return true;
}
Player_SetSpawnInfo(playerid) {
SetSpawnInfo(playerid, 0, 5, 5.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return true;
}
public OnPlayerCommandText(playerid, cmdtext[]) {
if(!strcmp(cmdtext, "/kill", true)) {
SpawnPlayer(playerid);
return true;
}
return false;
}
|
That's a good question. I didn't know, so I went ahead and tested it for you. It seems like the data set with SetSpawnInfo is being remembered until changed. This means that if you don't call SetSpawnInfo somewhere else, that you will always spawn back with the data you entered first.
Test code: PHP код:
|

#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS 1
new class_id[MAX_PLAYERS];
main() { }
public OnGameModeInit() {
AddPlayerClass(0, 5.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
AddPlayerClass(5, 10.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
AddPlayerClass(10, 13.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
AddPlayerClass(15, 15.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
return true;
}
public OnGameModeExit() {
return true;
}
public OnPlayerConnect(playerid) {
return true;
}
public OnPlayerRequestClass(playerid, classid) {
class_id[playerid] = classid;
return true;
}
public OnPlayerRequestSpawn(playerid) {
if(class_id[playerid] == 0) {
// CJ
SetSpawnInfo(playerid, 0, 0, 30.0, 5.0, 5.0, 180.0, 0, 0, 0, 0, 0, 0);
}
SpawnPlayer(playerid);
return true;
}
public OnPlayerCommandText(playerid, cmdtext[]) {
if(!strcmp(cmdtext, "/kill", true)) {
SetPlayerHealth(playerid, 0.0);
return true;
}
if(!strcmp(cmdtext, "forceselection", true)) {
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid, true);
TogglePlayerSpectating(playerid, false);
return true;
}
return false;
}
|
This function can be used to change the spawn information of a specific player. It allows you to automatically set someone's spawn weapons, their team, skin and spawn position, normally used in case of minigames or automatic-spawn systems. This function is more crash-safe then using SetPlayerSkin in OnPlayerSpawn and/or OnPlayerRequestClass, even though this has been fixed in 0.2. |