23.01.2010, 06:21
Quote:
Originally Posted by mansonh
Untested but i think this is what you are looking for.
Code:
new President= -1; public OnPlayerSpawn(playerid) { if(President==-1) { President=playerid; } } public OnPlayerDisconnect(playerid, reason) { if(playerid == President) { SelectNewPresident(playerid, "disconnected"); } } public OnPlayerDeath(playerid, killerid, reason) { if(playerid == President) { SelectNewPresident(playerid, "died"); } } stock SelectNewPresident(PreviousPres, reason[]) { new playerid; while(President==PreviousPres) { playerid = Random(MAX_PLAYERS-1); if(IsPlayerConnected(playerid)) { President==playerid; } } new msg[128], new prevName[24], newName[24]; GetPlayerName(PreviousPres, prevName, sizeof(prevName)); GetPlayerName(President, newName, sizeof(newName)); format(msg, sizeof(msg), "President %s has %s, %s has become President", prevName, reason, newName); SendClientMessageToAll(0xDEEE20FF, msg); } |