06.07.2015, 11:59
Hey , i want to know if its possible like , when a player type /setspawn , for each place he types it saves and when he respawns he spawn on that spawns.. Is it possible?
new myVar[MAX_PLAYERS]; new Float:RandomSpawn[][4] = { //positions, (X, Y, Z and facing angle) {-2796.9854, 1224.8180, 20.5429, 192.0335}, {-2454.2170, 503.8759, 30.0790, 267.2932}, {-2669.7322, -6.0874, 6.1328, 89.8853} }; public OnPlayerConnect(playerid) { myVar[playerid] = -1; //reset the variable to -1 return 1; } public OnPlayerSpawn(playerid) { if(myArray[playerid] != -1); { SetPlayerPos(playerid, RandomSpawn[myVar[playerid]][0], RandomSpawn[myVar[playerid]][1],RandomSpawn[myVar[playerid]][2]); //setPlayerPos to the random spawn data SetPlayerFacingAngle(playerid, RandomSpawn[myVar[playerid]][3]); //setPlayerFacingAngle to the random facing angle data } return 1; } CMD:randomspawn(playerid, params[]) { myVar[playerid] = random(sizeof(RandomSpawn)); //generate random number up to the size of the 'RandomSpawn' array. return 1; }
CMD:setspawn(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, -1, "You must be on-foot to use this command.");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
SetSpawnInfo(playerid, GetPlayerTeam(playerid), GetPlayerSkin(playerid), x, y, z, a, 0, 0, 0, 0, 0, 0);
SendClientMessage(playerid, 0xFFFF00FF, "Position saved. You will spawn here next time you respawn.");
return 1;
}
Hmm not really I tried my self and then came here.. I could possibly do it for 1 position , but I wanted to know how could I do for more.
|