02.05.2013, 12:04
Hey Guys,
I used a part of a other gamemode "grandlarc", but when i press the fire key (left mouse button) i get kicked from the server closed connection. While i made a return and force another class selection so it re-runs the if statement but for some reason sa-mp kicks me and temp bans me so i have to restart the server this is my code.
Thanks in advance!
I used a part of a other gamemode "grandlarc", but when i press the fire key (left mouse button) i get kicked from the server closed connection. While i made a return and force another class selection so it re-runs the if statement but for some reason sa-mp kicks me and temp bans me so i have to restart the server this is my code.
Код:
/* Class Selection */ public OnPlayerRequestClass(playerid, classid) { if(playersInfo[playerid][pFaction] == 0) { PlayerFactionSelected[playerid] = -1; PlayerFactionSelection[playerid] = 0; PlayerFactionSelectedtick[playerid] = GetTickCount(); TogglePlayerSpectating(playerid, 1); TextDrawShowForPlayer(playerid, txtClassSelHelper); Class_FactionHandle(playerid); playersInfo[playerid][pStatus] = PLAYER_STATUS_LOGGED_IN; } else { TogglePlayerSpectating(playerid, 0); SelectSkin(playerid, classid); } return 1; } forward SelectSkin(playerid, classid); public SelectSkin(playerid, classid) { SetPlayerPos(playerid,1984.4445,157.9501,55.9384); SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384); SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384); SetPlayerFacingAngle(playerid,0.0); return 1; } /* Class Selection */ Class_FactionHandle(playerid) { new Keys,ud,lr; GetPlayerKeys(playerid,Keys,ud,lr); if(PlayerFactionSelection[playerid] == 0) { Class_SwitchToNextFaction(playerid); return; } // only allow new selection every ~500 ms if( (GetTickCount() - PlayerFactionSelectedtick[playerid]) < 500 ) return; if(Keys & KEY_FIRE) { playersInfo[playerid][pFaction] = PlayerFactionSelection[playerid]; new query[250]; format(query, sizeof(query), "UPDATE `users` SET `user_faction` = '%d' WHERE `user_id` = '%d';", playersInfo[playerid][pFaction], playersInfo[playerid][pID]); mysql_query(mysql, query, QUERY_THREADED); TextDrawHideForPlayer(playerid,txtClassSelHelper); TextDrawHideForPlayer(playerid,txtRepublicans); TextDrawHideForPlayer(playerid,txtLiberators); playersInfo[playerid][pStatus] = PLAYER_STATUS_LOGGED_IN; TogglePlayerSpectating(playerid, 0); ForceClassSelection(playerid); return; } if(lr > 0) { Class_SwitchToNextFaction(playerid); } else if(lr < 0) { Class_SwitchToPreviousFaction(playerid); } } Class_SwitchToPreviousFaction(playerid) { PlayerFactionSelection[playerid]--; if(PlayerFactionSelection[playerid] < Team_Liberators) { PlayerFactionSelection[playerid] = Team_Republicans; } PlayerPlaySound(playerid,1053,0.0,0.0,0.0); PlayerFactionSelectedtick[playerid] = GetTickCount(); Class_SetupSelectedFaction(playerid); } Class_SwitchToNextFaction(playerid) { PlayerFactionSelection[playerid]++; if(PlayerFactionSelection[playerid] > Team_Republicans) { PlayerFactionSelection[playerid] = Team_Liberators; } PlayerPlaySound(playerid,1052,0.0,0.0,0.0); PlayerFactionSelectedtick[playerid] = GetTickCount(); Class_SetupSelectedFaction(playerid); } Class_SetupSelectedFaction(playerid) { if(PlayerFactionSelection[playerid] == 1) { PlayerFactionSelection[playerid] = Team_Liberators; } if(PlayerFactionSelection[playerid] == Team_Liberators) { SetPlayerInterior(playerid,0); SetPlayerCameraPos(playerid,1630.6136,-2286.0298,110.0); SetPlayerCameraLookAt(playerid,1887.6034,-1682.1442,47.6167); TextDrawShowForPlayer(playerid,txtRepublicans); TextDrawHideForPlayer(playerid,txtLiberators); } else if(PlayerFactionSelection[playerid] == Team_Republicans) { SetPlayerInterior(playerid,0); SetPlayerCameraPos(playerid,-1300.8754,68.0546,129.4823); SetPlayerCameraLookAt(playerid,-1817.9412,769.3878,132.6589); TextDrawHideForPlayer(playerid,txtRepublicans); TextDrawShowForPlayer(playerid,txtLiberators); } } Class_InitTextDraws() { // Init our observer helper text display txtRepublicans = TextDrawCreate(10.0, 380.0, "Republicans"); Class_InitFactionNameText(txtRepublicans); txtLiberators = TextDrawCreate(10.0, 380.0, "Liberators"); Class_InitFactionNameText(txtLiberators); // Init our observer helper text display txtClassSelHelper = TextDrawCreate(150.0, 15.0, " Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to choose Faction.~n~ Press ~r~~k~~PED_FIREWEAPON~ ~w~to select."); TextDrawLetterSize(txtClassSelHelper,0.3,1.0); TextDrawTextSize(txtClassSelHelper,160.0,15.0); TextDrawFont(txtClassSelHelper, 2); TextDrawSetShadow(txtClassSelHelper,0); TextDrawSetOutline(txtClassSelHelper,1); TextDrawBackgroundColor(txtClassSelHelper,0x000000FF); TextDrawColor(txtClassSelHelper,0xFFFFFFFF); } Class_InitFactionNameText(Text:txtInit) { TextDrawUseBox(txtInit, 0); TextDrawLetterSize(txtInit,1.25,3.0); TextDrawFont(txtInit, 0); TextDrawSetShadow(txtInit,0); TextDrawSetOutline(txtInit,1); TextDrawColor(txtInit,0xEEEEEEFF); TextDrawBackgroundColor(txtClassSelHelper,0x000000FF); }