10.04.2020, 19:35
Code:
HandleContract(playerid, killerid) { if(GetFactionType(killerid) == FACTION_HITMAN && PlayerInfo[killerid][pContractTaken] == playerid) { new price = PlayerInfo[playerid][pContracted]; SendClientMessageEx(killerid, COLOR_YELLOW, "You have completed your contract on %s and received $%i.", GetPlayerRPName(playerid), price); SendClientMessageEx(playerid, COLOR_YELLOW, "You have been killed by a hitman and lost $%i.", price); GivePlayerCash(playerid, -price); GivePlayerCash(killerid, price); PlayerInfo[killerid][pContractTaken] = INVALID_PLAYER_ID; PlayerInfo[killerid][pCompletedHits]++; PlayerInfo[playerid][pContracted] = 0; PlayerInfo[playerid][pContractBy] = 0; mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET contracted = 0, contractby = 'Nobody' WHERE uid = %i", PlayerInfo[playerid][pID]); mysql_tquery(connectionID, queryBuffer); mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET completedhits = %i WHERE uid = %i", PlayerInfo[killerid][pCompletedHits], PlayerInfo[killerid][pID]); mysql_tquery(connectionID, queryBuffer); foreach(new i : Player) { if(PlayerInfo[i][pContractTaken] == playerid) { PlayerInfo[i][pContractTaken] = INVALID_PLAYER_ID; } } Log_Write("log_contracts", "%s (uid: %i) successfully completed their hit on %s (uid: %i) for $%i.", GetPlayerRPName(killerid), PlayerInfo[killerid][pID], GetPlayerRPName(playerid), PlayerInfo[playerid][pID], price); else if(PlayerInfo[playerid][pContractTaken] == killerid) { new price = PlayerInfo[killerid][pContracted]; SendClientMessageEx(playerid, COLOR_YELLOW, "You have failed your contract on %s and lost $%i.", GetPlayerRPName(playerid), price); SendClientMessageEx(killerid, COLOR_YELLOW, "You have killed a hitman chasing after you and received $%i. The contract on your head has been removed.", price); GivePlayerCash(playerid, -price); GivePlayerCash(killerid, price); PlayerInfo[playerid][pContractTaken] = INVALID_PLAYER_ID; PlayerInfo[playerid][pFailedHits]++; PlayerInfo[killerid][pContracted] = 0; PlayerInfo[killerid][pContractBy] = 0; mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET contracted = 0, contractby = 'Nobody' WHERE uid = %i", PlayerInfo[killerid][pID]); mysql_tquery(connectionID, queryBuffer); mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET failedhits = %i WHERE uid = %i", PlayerInfo[playerid][pFailedHits], PlayerInfo[playerid][pID]); mysql_tquery(connectionID, queryBuffer); foreach(new i : Player) { if(PlayerInfo[i][pContractTaken] == killerid) { PlayerInfo[i][pContractTaken] = INVALID_PLAYER_ID; } } Log_Write("log_contracts", "%s (uid: %i) failed their hit on %s (uid: %i) and lost $%i.", GetPlayerRPName(playerid), PlayerInfo[playerid][pID], GetPlayerRPName(killerid), PlayerInfo[killerid][pID], price); } } }