29.06.2011, 05:08
Spec is randomly chaneging players, but i dont know why... do anyone know how to fix that bug?
spectatetimer = SetTimer("Spectator", 1500, 1);
Код:
if (strcmp(cmd, "/spec", true) == 0) // Moddded By DraGoN { if(IsPlayerConnected(playerid)) { if (PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid) || PlayerInfo[playerid][pGameMaster] >= 1 || PlayerInfo[playerid][pBanPower] >= 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD1, "Koriscenje: /spec [playerID/DeoImena]"); return 1; } giveplayerid = ReturnUser(tmp); new Float:Health, Float:Armour; new World = GetPlayerVirtualWorld(playerid); new PlInterior = GetPlayerInterior(playerid); new weaponid, ammo; GetPlayerHealth(playerid, Health); GetPlayerArmour(playerid, Armour); if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(Spectate[playerid] == 255) { GetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]); if(PlayerInfo[playerid][pAdmin] >= 6) { if(PlayerInfo[playerid][pAdminDuty] == 1) { for(new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, weaponid, ammo); OtherWeapons[playerid][i] = weaponid; OtherAmmo[playerid][i] = ammo; } SpHealth[playerid] = Health; SpArmour[playerid] = Armour; } else { SaveGuns(playerid); PlayerInfo[playerid][pHealth] = Health; PlayerInfo[playerid][pArmour] = Armour; } } else { SaveGuns(playerid); PlayerInfo[playerid][pHealth] = Health; PlayerInfo[playerid][pArmour] = Armour; } } Interior[playerid] = PlInterior; VirWorld[playerid] = World; TogglePlayerSpectating(playerid, 1); if(IsPlayerInAnyVehicle(giveplayerid)) { PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid)); } else { PlayerSpectatePlayer(playerid, giveplayerid); } Spectate[playerid] = giveplayerid; SafeSetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "[ADMIN]: %s Is Now Spectating %s (%d).", sendername, giveplayer, giveplayerid); SendAdminMessage(COLOR_LIGHTRED,string); SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Ne gledate ovog igraca. Da biste prestali sa spec-om ili da biste spec-ovali drugog igraca kucajte /endspec <playerid>"); TextDrawHideForPlayer(playerid, Textdraw44); TextDrawHideForPlayer(playerid, Textdraw45); TextDrawHideForPlayer(playerid, Textdraw55); TextDrawHideForPlayer(playerid, Textdraw51[playerid]); TextDrawShowForPlayer(playerid, Textdraw54[playerid]); if(PlayerInfo[playerid][pWatch] == 1) { TextDrawHideForPlayer(playerid, Textdraw56); TextDrawHideForPlayer(playerid, Textdraw57); TextDrawHideForPlayer(playerid, Textdraw58); } new y, m, d; new h,mi,s; getdate(y,m,d); gettime(h,mi,s); format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s gleda igraca %s's",d,m,y,h,mi,s,sendername,giveplayer); AdminLog(string); } } else { SendClientMessage(playerid, COLOR_GRAD1, " Igrac ne postoji!"); } } else { SendClientMessage(playerid, COLOR_GRAD1, " Niste Administrator!"); } } return 1; }
Код:
public Spectator() { new string[350]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Spectate[i] != 255) { new targetid = Spectate[i]; if(IsPlayerConnected(targetid)) { if(PlayerInfo[i][pAdmin] >= 1) { new Float:health,Float:armour,Float:health2; new name[MAX_PLAYER_NAME]; new money = GetPlayerMoney(targetid); new carid = GetPlayerVehicleID(targetid); new kmh = GetPlayerSpeed(targetid, true); new bankmoney = PlayerInfo[targetid][pNalog]; GetPlayerName(targetid, name, sizeof(name)); GetPlayerHealth(targetid, health); GetPlayerArmour(targetid, armour); GetVehicleHealth(carid, health2); if(!IsPlayerInAnyVehicle(targetid)) { format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Helti: ~w~%.1f ~g~:-: ~b~Pancir: ~w~%.1f ~n~ ~b~Pare: ~w~$%d ~g~:-: ~b~Banka: ~w~$%d",name,targetid,health,armour,money,bankmoney); TextDrawSetString(Textdraw54[i],string); } else { format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Helti: ~w~%.1f ~g~:-: ~b~Pancir: ~w~%.1f ~n~ ~b~Pare: ~w~$%d ~g~:-: ~b~Banka: ~w~$%d ~n~~n~~g~---------------------------------------------------~n~~n~ ~b~ID vozila: ~w~%d ~b~Helti vozila: ~w~%.1f ~n~~n~~b~Brzina: ~w~%d",name,targetid,health,armour,money,bankmoney,carid,health2,kmh); TextDrawSetString(Textdraw54[i],string); } } if(GetPlayerInterior(targetid) > 0) { SafeSetPlayerInterior(i,GetPlayerInterior(targetid)); } if(GetPlayerVirtualWorld(targetid) > 0) { SetPlayerVirtualWorld(i,GetPlayerVirtualWorld(targetid)); } }//Targetid connected } } } }
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Spectate[i] != 255) { PlayerSpectateVehicle(i,vehicleid); } } } return 1; }
Код:
OnPlayerConnect { Spectate[playerid] = 255; Unspec[playerid][sLocal] = 255; AdminSpec[playerid] = 0; return 1; }
Код:
public SetPlayerSpawn(playerid) if(Spectate[playerid] != 255) { SafeSetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]); SafeSetPlayerInterior(playerid, Interior[playerid]); SetPlayerVirtualWorld(playerid, VirWorld[playerid]); if(PlayerInfo[playerid][pAdmin] >= 6) { if(PlayerInfo[playerid][pAdminDuty] == 1) { SetPlayerHealth(playerid, SpHealth[playerid]); SetPlayerArmour(playerid, SpArmour[playerid]); } else { SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]); SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]); } } else { SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]); SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]); } SetPlayerWeapons(playerid); SetPlayerToTeamColor(playerid); Spectate[playerid] = 255; TextDrawShowForPlayer(playerid, Textdraw44); TextDrawShowForPlayer(playerid, Textdraw45); TextDrawShowForPlayer(playerid, Textdraw55); TextDrawShowForPlayer(playerid, Textdraw51[playerid]); TextDrawHideForPlayer(playerid, Textdraw54[playerid]); if(PlayerInfo[playerid][pWatch] == 1) { TextDrawShowForPlayer(playerid, Textdraw56); TextDrawShowForPlayer(playerid, Textdraw57); TextDrawShowForPlayer(playerid, Textdraw58); } return 1; }
Код:
public OnPlayerExitVehicle(playerid, vehicleid) { for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Spectate[i] != 255) { PlayerSpectatePlayer(i,playerid); } } } return 1; }