Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Alive[playerid] = 0;
- CheckDelay[playerid] = 10;
- TextDrawHideForPlayer(playerid, Status[playerid]);
- new vehicleid = GetPlayerVehicleID(playerid);
- if(vehicleVariables[vehicleid][vVehicleJob] == 7)
- {
- format(szMessage, sizeof(szMessage), "Job failed.");
- SCM(playerid, COLOR_NOB, szMessage);
- SetVehicleToRespawnEx(vehicleid);
- KillTimer(mowertimer[playerid]);
- MowerMoney[playerid] = 0;
- TextDrawHideForPlayer(playerid,Mower[playerid]);
- playerVariables[playerid][pFarmerMoney] = 0;
- }
- if(PlayerPaintballing[playerid] != 0)
- {
- foreach(Player, x)
- {
- if((PlayerPaintballing[playerid] != 0 && PlayerPaintballing[killerid] != 0) && PlayerPaintballing[x])
- {
- SendDeathMessageToPlayer(x, killerid, playerid, reason);
- }
- }
- new string[500];
- new pinfo[128];
- KillP[killerid]++;
- DeathP[playerid]++;
- format(string, sizeof(string), "You have killed %s. You now have %d kills.",GetName(playerid), KillP[killerid]);
- SendClientMessage(killerid, COLOR_GENANNOUNCE, string);
- format(string, sizeof(string), "You have been killed by %s.",GetName(killerid));
- SendClientMessage(playerid, COLOR_GENANNOUNCE, string);
- PlayerPaintballScore[killerid] = KillP[killerid];
- if(PlayerPaintballScore[killerid] > PaintballWinnerScore)
- {
- PaintballWinner = killerid;
- PaintballWinnerScore = PlayerPaintballScore[killerid];
- foreach(Player,i)
- {
- if(IsPlayerConnected(i))
- {
- if(PlayerPaintballing[i] != 0)
- {
- format(pinfo,sizeof(pinfo),"%s is now in lead with %d kills.",GetName(PaintballWinner),PaintballWinnerScore);
- SCM(i, COLOR_YELLOW, pinfo);
- }
- }
- }
- }
- return 1;
- }
- KillTimer(mowertimer[playerid]);
- if(playerVariables[playerid][pHeadValue] > 0)
- {
- if(IsPlayerConnected(killerid))
- {
- if(playerVariables[killerid][pGroup] == 12)
- {
- if(GoChase[killerid] == playerid)
- {
- new string[256];
- new killer[MAX_PLAYER_NAME];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(killerid, killer, sizeof(killer));
- GetPlayerName(playerid, name, sizeof(name));
- playerVariables[killerid][pMoney] += playerVariables[playerid][pHeadValue];
- format(string,128,"%s has succesfully completed the contract on %s for $%d, distance: %.0fm.",killer,name,playerVariables[playerid][pHeadValue], GetDistanceBetweenPlayers(killerid, playerid));
- SendToGroup(12, COLOR_HIT, string);
- playerVariables[playerid][pHeadValue] = -1;
- GotHit[playerid] = 0;
- GetChased[playerid] = 999;
- GoChase[killerid] = 999;
- }
- }
- }
- }
- new turfkiller, turfplayerid;
- for(new i = 0; i <= sizeof(TurfInfo); i++)
- {
- if(IsPlayerInTurf(playerid, i) == 1)
- {
- turfplayerid = i;
- break;
- }
- }
- for(new i = 0; i <= sizeof(TurfInfo); i++)
- {
- if(IsPlayerInTurf(killerid, i) == 1)
- {
- turfkiller = i;
- break;
- }
- }
- new string[256];
- if(WarInfo[turfplayerid][wTime] > 0 && WarInfo[turfkiller][wTime] > 0)
- {
- if(turfplayerid == turfkiller)
- {
- if(playerVariables[playerid][pGroup] == WarInfo[turfplayerid][wAttacker] && playerVariables[killerid][pGroup] == WarInfo[turfplayerid][wFaction])
- {
- playerVariables[playerid][pWarDeaths] += 1;
- format(string, sizeof(string), "You have been killed by %s (%i)", playerVariables[killerid][pNormalName], killerid);
- SCM(playerid, COLOR_GENANNOUNCE, string);
- groupVariables[WarInfo[turfkiller][wFaction]][gScore] += 1;
- playerVariables[killerid][pWarScore] += 1;
- format(string, sizeof(string), "You have killed %s (%i).", playerVariables[playerid][pNormalName], playerid);
- SCM(killerid, COLOR_GENANNOUNCE, string);
- foreach(Player, x)
- {
- if(playerVariables[x][pGroup] == WarInfo[turfplayerid][wAttacker] || playerVariables[x][pGroup] == WarInfo[turfplayerid][wFaction])
- {
- SendDeathMessageToPlayer(x, killerid, playerid, reason);
- }
- }
- SCM(playerid, COLOR_LIGHTBLUE, "You will be spawned in the HQ.");
- }
- else if(playerVariables[killerid][pGroup] == WarInfo[turfkiller][wAttacker] && playerVariables[playerid][pGroup] == WarInfo[turfkiller][wFaction])
- {
- playerVariables[playerid][pWarDeaths] += 1;
- format(string, sizeof(string), "You have been killed by %s (%i).", playerVariables[killerid][pNormalName], killerid);
- SCM(playerid, COLOR_GENANNOUNCE, string);
- groupVariables[WarInfo[turfplayerid][wAttacker]][gScore] += 1;
- playerVariables[killerid][pWarScore] += 1;
- format(string, sizeof(string), "You have killed %s (%i).", playerVariables[playerid][pNormalName], playerid);
- SCM(killerid, COLOR_GENANNOUNCE, string);
- foreach(Player, x)
- {
- if(playerVariables[x][pGroup] == WarInfo[turfplayerid][wAttacker] || playerVariables[x][pGroup] == WarInfo[turfplayerid][wFaction])
- {
- SendDeathMessageToPlayer(x, killerid, playerid, reason);
- }
- }
- SCM(playerid, COLOR_LIGHTBLUE, "You will be spawned in group HQ.");
- }
- }
- }
- if((WarInfo[turfkiller][wTime] != 0 && (WarInfo[turfkiller][wAttacker] == playerVariables[playerid][pGroup] || WarInfo[turfkiller][wFaction] == playerVariables[playerid][pGroup]) && playerVariables[playerid][pGroup] != 0) || (playerVariables[killerid][pGroup] == 1
- || playerVariables[killerid][pGroup] == 2 || playerVariables[killerid][pGroup] == 3 || playerVariables[killerid][pGroup] == 5) || (playerVariables[playerid][pGroup] == 1 || playerVariables[playerid][pGroup] == 2 || playerVariables[playerid][pGroup] == 3 || playerVariables[playerid][pGroup] == 5) || (playerVariables[playerid][pGroup] == playerVariables[killerid][pGroup]) || (PlayerPaintballing[killerid] >= 1))
- {
- }
- else
- {
- WantedID[playerid] = killerid;
- SCM(playerid, COLOR_GENANNOUNCE, "You have been attacked by another player. You have 60 seconds to call the police to report this crime. Use /call 112.");
- WantedIDTime[playerid] = 60;
- }
- //SetTimerEx("Spawn", 3999, 0, "d", playerid);
- SetPlayerHealth(playerid, 0);
- killerid = INVALID_PLAYER_ID;
- return 1;
- }
- stock savePlayerData(const playerid)
- {
- if(playerVariables[playerid][pStatus] >= 1 || playerVariables[playerid][pStatus] == -1)
- {
- new saveQuery[1000];
- if(playerVariables[playerid][pStatus] == -1) playerVariables[playerid][pStatus] = 0;
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerBanned = '%d', playerSeconds = '%d', playerSkin = '%d', playerMoney = '%d', playerBankMoney = '%d', playerHouse = '%d', playerBusiness = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pBanned], playerVariables[playerid][pSeconds], playerVariables[playerid][pSkin], playerVariables[playerid][pMoney], playerVariables[playerid][pBankMoney], playerVariables[playerid][pHouse], playerVariables[playerid][pBusiness],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerColor = '%d', playerInterior = '%d', playerVirtualWorld = '%d', playerHealth = '%f', playerArmour = '%f', playerBoatLic = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pColor], playerVariables[playerid][pInterior], playerVariables[playerid][pVirtualWorld], playerVariables[playerid][pHealth], playerVariables[playerid][pArmour], playerVariables[playerid][pBoatLicense],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerAdminLevel = '%d', playerJob = '%d', playerWeapon0 = '%d', playerWeapon1 = '%d', playerWeapon2 = '%d', playerWeapon3 = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pAdminLevel], playerVariables[playerid][pJob], playerVariables[playerid][pWeapons][0], playerVariables[playerid][pWeapons][1], playerVariables[playerid][pWeapons][2], playerVariables[playerid][pWeapons][3],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerWeapon4 = '%d', playerWeapon5 = '%d', playerWeapon6 = '%d', playerWeapon7 = '%d', playerWeapon8 = '%d', playerWeapon9 = '%d', playerWeapon10 = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pWeapons][4], playerVariables[playerid][pWeapons][5], playerVariables[playerid][pWeapons][6], playerVariables[playerid][pWeapons][7], playerVariables[playerid][pWeapons][8], playerVariables[playerid][pWeapons][9], playerVariables[playerid][pWeapons][10],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerWeapon11 = '%d', playerWeapon12 = '%d', playerJobSkill2 = '%d', playerMaterials = '%d', playerHours = '%d', playerLevel = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pWeapons][11], playerVariables[playerid][pWeapons][12], playerVariables[playerid][pDonate], playerVariables[playerid][pMaterials], playerVariables[playerid][pPlayingHours], playerVariables[playerid][pLevel],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerWarning1 = '%s', playerWarning2 = '%s', playerWarning3 = '%s', playerHospitalized = '%d', playerFirstLogin = '%d', playerAdminName = '%s', playerPrisonTime = '%d', playerPrisonID = '%d', playerPhoneNumber = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pCarLic], playerVariables[playerid][pFlyLic], playerVariables[playerid][pGunLic], playerVariables[playerid][pHospitalized], playerVariables[playerid][pFirstLogin], playerVariables[playerid][pCrimeReason],
- playerVariables[playerid][pPrisonTime], playerVariables[playerid][pPrisonID], playerVariables[playerid][pPhoneNumber],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarPaintJob = '%d', playerCarLock = '%d', playerStatus = '%d', playerGender = '%d', playerFightStyle = '%d', playerCarWeapon1 = '%d', playerCarWeapon2 = '%d', playerCarWeapon3 = '%d', playerCarWeapon4 = '%d', playerCarWeapon5 = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pCarPaintjob], playerVariables[playerid][pCarLock],
- playerVariables[playerid][pStatus], playerVariables[playerid][pGender], playerVariables[playerid][pFightStyle], playerVariables[playerid][pCarWeapons], playerVariables[playerid][pFPunish], playerVariables[playerid][pFWarns], playerVariables[playerid][pSpawnChange], playerVariables[playerid][pPremiumPoints], playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarTrunk1 = '%d', playerCarTrunk2 = '%d', playerPhoneCredit = '%d', playerWalkieTalkie = '%d', playerFlyLic = '%d', playerGunLic = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pCarKM], playerVariables[playerid][pDrugs], playerVariables[playerid][pPhoneCredit], playerVariables[playerid][pWalkieTalkie],playerVariables[playerid][pFlyLicense],playerVariables[playerid][pGunLicense],playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerPhoneBook = '%d', playerGroup = '%d', playerGroupRank = '%d', playerRope = '%d', playerAdminDuty = '%d', playerCrimes = '%d', playerArrests = '%d', playerWarrants = '%d', playerAge = '%d', playerCarMod7 = '%d', playerCarMod8 = '%d', playerCarMod9 = '%d', playerCarMod10 = '%d', playerCarMod11 = '%d', playerCarMod12 = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pPhoneBook],playerVariables[playerid][pGroup], playerVariables[playerid][pGroupRank], playerVariables[playerid][pDriveLicense], playerVariables[playerid][pRobPoints], playerVariables[playerid][pCrimes], playerVariables[playerid][pArrests], playerVariables[playerid][pWarrants], playerVariables[playerid][pRPoints], playerVariables[playerid][pCarMods1][7], playerVariables[playerid][pCarMods1][8],
- playerVariables[playerid][pCarMods1][9], playerVariables[playerid][pCarMods1][10], playerVariables[playerid][pCarMods1][11], playerVariables[playerid][pCarMods1][12], playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerHelperLevel = '%d', playerClan = '%d', playerClanRank = '%d', playerPhone = '%d', playerManager = '%d', playerClanTagType = '%d', playerHelpedPlayers = '%d', playerHelperTokens = '%d', playerHouseRented = '%d', playerGlasses = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pHelper],playerVariables[playerid][pClan],playerVariables[playerid][pClanRank],playerVariables[playerid][pPhone],playerVariables[playerid][pManager],playerVariables[playerid][pClanTagType],
- playerVariables[playerid][pHelpedPlayers],playerVariables[playerid][pHelperTokens],playerVariables[playerid][pHouseRented],playerVariables[playerid][pGlasses], playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerGiftHours = %d, playerHud = '%d', playerInsurance = '%d', playerInsurance2 = '%d', playerInsurance3 = '%d', playerInsurance4 = '%d', playerInsurancePoints = '%d', playerInsurancePoints2 = '%d', playerInsurancePoints3 = '%d', playerInsurancePoints4 = '%d' WHERE playerID = '%d'",
- playerVariables[playerid][pGiftHours],playerVariables[playerid][ShowHealth],playerVariables[playerid][pInsurance],playerVariables[playerid][pInsurance2],playerVariables[playerid][pInsurance3],playerVariables[playerid][pInsurance4],playerVariables[playerid][pInsurancePoints],playerVariables[playerid][pInsurancePoints2],playerVariables[playerid][pInsurancePoints3],playerVariables[playerid][pInsurancePoints4], playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,saveQuery);
- }
- return 1;
- }
- stock doesVehicleExist(const vehicleid)
- {
- if(GetVehicleModel(vehicleid) >= 400)
- {
- return 1;
- }
- return 0;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- #if defined DEBUG
- printf("[debug] OnPlayerDisconnect(%d, %d)", playerid, reason);
- #endif
- TextDrawDestroy(Status[playerid]);
- Distance[playerid] = 0;
- Alive[playerid] = 0;
- CheckDelay[playerid] = 0;
- SpawnTimes[playerid] = 0;
- ServerNews[playerid] = 0;
- playerVariables[playerid][pFarmerMoney] = 0;
- PlayerPaintballing[playerid] = 0;
- KillTimer(mowertimer[playerid]);
- SetPlayerName(playerid, playerVariables[playerid][pNormalName]);
- savePlayerData(playerid);
- if(GotHit[playerid] != 0)
- {
- new id = GoChase[playerid];
- GotHit[playerid] = 0;
- GoChase[playerid] = 999;
- GetChased[id] = 999;
- format(szMessage, sizeof(szMessage), "Your target has left the game. Use /contracts to see other targets.");
- SCM(id, COLOR_TEAL, szMessage);
- }
- if(GetChased[playerid] != 999)
- {
- GetChased[playerid] = 999;
- }
- new year, month, day, hour, minute, second;
- getdate(year, month, day);
- gettime(hour, minute, second);
- format(playerVariables[playerid][pLastLogin], 20, "%02d.%02d.%d %02d:%02d", day, month, year, hour, minute);
- new query[256];
- format(query, sizeof(query), "UPDATE playeraccounts SET playerLastLogin = '%s' WHERE playerID = '%d'", playerVariables[playerid][pLastLogin], playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,query);
- if(playerVariables[playerid][pStatus] >= 1)
- {
- playerVariables[playerid][pStatus] = -1;
- foreach(Player, x)
- {
- if(playerVariables[x][pSpectating] == playerid)
- {
- TextDrawHideForPlayer(x, info[x]);
- TextDrawHideForPlayer(x, carspeed[x]);
- TextDrawHideForPlayer(x, carinfo[x]);
- TextDrawHideForPlayer(x, viata[x]);
- TextDrawHideForPlayer(x, wantedjail[x]);
- TogglePlayerSpectating(x, 0);
- SendClientMessage(x, COLOR_GREY, "The player you were spectating has disconnected.");
- }
- }
- if(TransportDuty[playerid] == 1)
- {
- TaxiDrivers -= 1;
- }
- if(TransportDuty[playerid] == 1)
- {
- TaxiDrivers -= 1;
- }
- if(TransportDuty[playerid] == 2)
- {
- BusDrivers -= 1;
- }
- foreach(Player, i)
- {
- if(TaxiAccepted[i] < 999)
- {
- if(TaxiAccepted[i] == playerid)
- {
- TaxiAccepted[i] = 999;
- GameTextForPlayer(i, "~w~Taxi Caller~n~~r~Left the game", 5000, 1);
- TaxiCallTime[i] = 0;
- DisablePlayerCheckpoint(i);
- }
- }
- if(MedicAccepted[i] < 999)
- {
- if(MedicAccepted[i] == playerid)
- {
- MedicAccepted[i] = 999;
- GameTextForPlayer(i, "~w~Taxi Caller~n~~r~Left the game", 5000, 1);
- MedicCallTime[i] = 0;
- DisablePlayerCheckpoint(i);
- }
- }
- }
- if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
- {
- if(IsPlayerConnected(TransportDriver[playerid]))
- {
- new string[64];
- TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
- TransportTime[TransportDriver[playerid]] = 0;
- TransportCost[TransportDriver[playerid]] = 0;
- format(string, sizeof(string), "~w~Passenger left~n~~g~Earned $%d",TransportCost[playerid]);
- GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
- }
- }
- if(playerVariables[playerid][pPhoneCall] != -1 && playerVariables[playerid][pPhoneCall] < MAX_PLAYERS)
- {
- SendClientMessage(playerVariables[playerid][pPhoneCall], COLOR_WHITE, "Your call has been terminated by the other party.");
- if(GetPlayerSpecialAction(playerVariables[playerid][pPhoneCall]) == SPECIAL_ACTION_USECELLPHONE)
- {
- SetPlayerSpecialAction(playerVariables[playerid][pPhoneCall], SPECIAL_ACTION_STOPUSECELLPHONE);
- }
- playerVariables[playerVariables[playerid][pPhoneCall]][pPhoneCall] = -1;
- }
- if(playerVariables[playerid][pAdminLevel] < 1)
- {
- switch(reason)
- {
- case 1: format(szMessage, sizeof(szMessage), "%s has left the server.", playerVariables[playerid][pNormalName]);
- case 2: format(szMessage, sizeof(szMessage), "%s has been kicked or banned from the server.", playerVariables[playerid][pNormalName]);
- default: format(szMessage, sizeof(szMessage), "%s has timed out from the server.", playerVariables[playerid][pNormalName]);
- }
- nearByMessage(playerid, COLOR_GENANNOUNCE, szMessage);
- }
- if(playerVariables[playerid][pGroup] >= 1)
- {
- switch(reason)
- {
- case 0:
- {
- format(szMessage, sizeof(szMessage), "%s from your group has disconnected (crash).", playerVariables[playerid][pNormalName]);
- }
- case 1:
- {
- format(szMessage, sizeof(szMessage), "%s from your group has disconnected (quit).", playerVariables[playerid][pNormalName]);
- }
- case 2:
- {
- format(szMessage, sizeof(szMessage), "%s from your group has disconnected (banned/kicked).", playerVariables[playerid][pNormalName]);
- }
- }
- SendToGroup(playerVariables[playerid][pGroup], COLOR_GENANNOUNCE, szMessage);
- }
- if(playerVariables[playerid][pCarModel1] >= 1)
- {
- DestroyVehicle(playerVariables[playerid][pCarID1]);
- Lock[playerVariables[playerid][pCarID1]] = 0;
- systemVariables[vehicleCounts][1]--;
- playerVariables[playerid][pCarID1] = -1;
- }
- if(playerVariables[playerid][pCarModel2] >= 1)
- {
- DestroyVehicle(playerVariables[playerid][pCarID2]);
- Lock[playerVariables[playerid][pCarID2]] = 0;
- systemVariables[vehicleCounts][1]--;
- playerVariables[playerid][pCarID2] = -1;
- }
- if(playerVariables[playerid][pCarModel3] >= 1)
- {
- DestroyVehicle(playerVariables[playerid][pCarID3]);
- Lock[playerVariables[playerid][pCarID3]] = 0;
- systemVariables[vehicleCounts][1]--;
- playerVariables[playerid][pCarID3] = -1;
- }
- if(playerVariables[playerid][pCarModel4] >= 1)
- {
- DestroyVehicle(playerVariables[playerid][pCarID4]);
- Lock[playerVariables[playerid][pCarID4]] = 0;
- systemVariables[vehicleCounts][1]--;
- playerVariables[playerid][pCarID4] = -1;
- }
- new mysqlquery[150];
- format(mysqlquery, 150, "UPDATE playeraccounts SET playerStatus = 0 WHERE playerID= '%d'", playerVariables[playerid][pInternalID]);
- mysql_tquery(handle,mysqlquery);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement