16.06.2013, 00:18
Hm !!! Coloca este !
//-------------------------------------------------------------------------------------------------------\\
forward Quadrilha_Timer(Quadrilha);
Quadrilha_Init()
{
for (new i; i < MAX_QUADRILHAS; i++)
{
AQuadrilha[i][QuadrilhaTextLeader] = TextDrawCreate(320.0, 1.0, " ");
TextDrawFont(AQuadrilha[i][QuadrilhaTextLeader], 2);
TextDrawLetterSize(AQuadrilha[i][QuadrilhaTextLeader], 0.399999,1.00000);
TextDrawSetShadow(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawAlignment(AQuadrilha[i][QuadrilhaTextLeader], 2);
TextDrawUseBox(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawBoxColor(AQuadrilha[i][QuadrilhaTextLeader] ,0x00000066);
AQuadrilha[i][QuadrilhaTextMember] = TextDrawCreate(320.0, 1.0, " ");
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 2);
TextDrawLetterSize(AQuadrilha[i][QuadrilhaTextMember], 0.399999,1.00000);
TextDrawSetShadow(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawAlignment(AQuadrilha[i][QuadrilhaTextMember], 2);
TextDrawUseBox(AQuadrilha[i][QuadrilhaTextMember], 1);
TextDrawBoxColor(AQuadrilha[i][QuadrilhaTextMember] ,0x00000066);
}
}
Quadrilha_Create(playerid, Quadrilha)
{
new Name[24], Msg[128];
GetPlayerName(playerid, Name, sizeof(Name));
if (Quadrilha_PlayerAllowed(playerid))
{
AQuadrilha[Quadrilha][Status] = QUADRILHA_OPEN;
AQuadrilha[Quadrilha][Members][0] = playerid;
APlayerData[playerid][InQuadrilha] = true;
APlayerData[playerid][QuadrilhaID] = Quadrilha;
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
AQuadrilha[Quadrilha][Members][i] = -1;
AQuadrilha[Quadrilha][QuadrilhaTimer] = SetTimerEx("Quadrilha_Timer", 1000, true, "i", Quadrilha);
format(Msg, 128, TXT_PlayerStartsQuadrilha, Name);
SendClientMessageToAll(0xFFFFFFFF, Msg);
}
}
Quadrilha_Join(playerid, Quadrilha)
{
new Name[24], Msg[128];
GetPlayerName(playerid, Name, sizeof(Name));
if (Quadrilha_PlayerAllowed(playerid))
{
if (Quadrilha_CountMembers(Quadrilha) < QUADRILHA_MAX_MEMBERS)
{
format(Msg, 128, TXT_PlayerJoinedQuadrilha, Name);
Quadrilha_SendMessage(Quadrilha, Msg);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_YouJoinedQuadrilha);
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] == -1)
{
AQuadrilha[Quadrilha][Members][i] = playerid;
break;
}
}
APlayerData[playerid][InQuadrilha] = true;
APlayerData[playerid][QuadrilhaID] = Quadrilha;
if (Quadrilha_CountMembers(Quadrilha) == QUADRILHA_MAX_MEMBERS)
AQuadrilha[Quadrilha][Status] = QUADRILHA_FULL;
TextDrawSetString(APlayerData[playerid][MissionText], TXT_WaitingLeaderJobQuadrilha);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaCheia);
}
}
Quadrilha_Leave(playerid)
{
new Quadrilha, NumMembers, MemberID;
if (APlayerData[playerid][InQuadrilha] == false)
return 1;
Quadrilha = APlayerData[playerid][QuadrilhaID];
NumMembers = Quadrilha_CountMembers(Quadrilha);
if (NumMembers == 1)
{
Quadrilha_Cancel(Quadrilha);
return 1;
}
APlayerData[playerid][InQuadrilha] = false;
APlayerData[playerid][QuadrilhaID] = 0;
TextDrawHideForPlayer(playerid, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
TextDrawHideForPlayer(playerid, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
if (APlayerData[playerid][JobStarted] == false)
TextDrawSetString(APlayerData[playerid][MissionText], Mafia_NoJobText);
if (AQuadrilha[Quadrilha][Members][0] == playerid)
{
for (new j = 1; j < QUADRILHA_MAX_MEMBERS; j++)
{
MemberID = AQuadrilha[Quadrilha][Members][j];
if (MemberID != -1)
{
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
AQuadrilha[Quadrilha][Members][0] = MemberID;
AQuadrilha[Quadrilha][Members][j] = -1;
return 1;
}
}
}
else
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] == playerid)
{
AQuadrilha[Quadrilha][Members][i] = -1;
Mafia_EndJob(playerid);
return 1;
}
}
}
return 1;
}
Quadrilha_Cancel(Quadrilha)
{
new MemberID;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
APlayerData[MemberID][InQuadrilha] = false;
APlayerData[MemberID][QuadrilhaID] = 0;
TextDrawFont(AQuadrilha[i][QuadrilhaTextLeader], 3);
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 3);
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
Mafia_EndJob(MemberID);
AQuadrilha[Quadrilha][Members][i] = -1;
SendClientMessage(MemberID, 0xFFFFFFFF, TXT_LeaderCancelledQuadrilha);
}
}
AQuadrilha[Quadrilha][LoadID] = 0;
AQuadrilha[Quadrilha][Location1] = 0;
AQuadrilha[Quadrilha][Location2] = 0;
AQuadrilha[Quadrilha][Status] = QUADRILHA_EMPTY;
AQuadrilha[Quadrilha][QuadrilhaStep] = 0;
KillTimer(AQuadrilha[Quadrilha][QuadrilhaTimer]);
}
Quadrilha_StartMemberJob(playerid, Quadrilha)
{
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float, Float:y, Float:z, LoadMsg[128];
APlayerData[playerid][JobStarted] = true;
APlayerData[playerid][LoadID] = AQuadrilha[Quadrilha][LoadID];
APlayerData[playerid][JobLoc1] = AQuadrilha[Quadrilha][Location1];
APlayerData[playerid][JobLoc2] = AQuadrilha[Quadrilha][Location2];
APlayerData[playerid][VehicleID] = GetPlayerVehicleID(playerid);
APlayerData[playerid][JobStep] = 1;
format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
format(RouteText, 255, TXT_HaulingCargoFromToPickup, Load, StartLoc, EndLoc);
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
x = ALocations[APlayerData[playerid][JobLoc1]][LocX];
y = ALocations[APlayerData[playerid][JobLoc1]][LocY];
z = ALocations[APlayerData[playerid][JobLoc1]][LocZ];
SetPlayerCheckpoint(playerid, x, y, z, 7);
APlayerData[playerid][VehicleTimerTime] = Job_TimeToFailMission;
format(LoadMsg, 128, TXT_PickupCargoAt, Load, StartLoc);
SendClientMessage(playerid, 0xFFFFFFFF, LoadMsg);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_MeetOtherQuadrilhaMembers);
}
Quadrilha_UpdateMemberJob(playerid)
{
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float, Float:y, Float:z, UnloadMsg[128];
APlayerData[playerid][JobStep] = 3;
format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
format(RouteText, 255, TXT_HaulingCargoFromToDeliver, Load, StartLoc, EndLoc);
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
x = ALocations[APlayerData[playerid][JobLoc2]][LocX];
y = ALocations[APlayerData[playerid][JobLoc2]][LocY];
z = ALocations[APlayerData[playerid][JobLoc2]][LocZ];
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(UnloadMsg, 128, TXT_DeliverCargoTo, Load, EndLoc);
SendClientMessage(playerid, 0xFFFFFFFF, UnloadMsg);
}
public Quadrilha_Timer(Quadrilha)
{
new LeaderID, MemberID;
Quadrilha_UpdateTextDraws(Quadrilha);
LeaderID = AQuadrilha[Quadrilha][Members][0];
switch (AQuadrilha[Quadrilha][QuadrilhaStep])
{
case 0:
{
new bool:AllSameTrailer = true;
if (APlayerData[LeaderID][JobStarted] == true)
{
AQuadrilha[Quadrilha][LoadID] = APlayerData[LeaderID][LoadID];
AQuadrilha[Quadrilha][Location1] = APlayerData[LeaderID][JobLoc1];
AQuadrilha[Quadrilha][Location2] = APlayerData[LeaderID][JobLoc2];
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
new vModel = GetVehicleModel(GetPlayerVehicleID(MemberID));
switch (vModel)
{
case VehicleSandKing, VehicleMoonbeam: AllSameTrailer = true;
default:
{
TextDrawSetString(APlayerData[MemberID][MissionText], "Vocк precisa de um SandKing ou Moombeam");
AllSameTrailer = false;
}
}
}
}
}
if (AllSameTrailer == true)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersSameVehicle);
for (new i = 1; i <QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
Quadrilha_StartMemberJob(MemberID, Quadrilha);
}
AQuadrilha[Quadrilha][QuadrilhaStep] = 1;
AQuadrilha[Quadrilha][Status] = QUADRILHA_CLOSED;
}
else
{
if (AQuadrilha[Quadrilha][LeaderInformedTrailers] == false)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersNotVehicle);
AQuadrilha[Quadrilha][LeaderInformedTrailers] = true;
}
}
}
}
case 1:
{
new bool:AllMembersLoaded = true;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
if (APlayerData[MemberID][JobStep] != 2)
AllMembersLoaded = false;
}
if (AllMembersLoaded == true)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersCarregados);
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
Quadrilha_UpdateMemberJob(MemberID);
}
AQuadrilha[Quadrilha][QuadrilhaStep] = 2;
}
}
case 2:
{
new bool:AllMembersUnloaded = true;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
if (APlayerData[MemberID][JobStep] != 4)
AllMembersUnloaded = false;
}
if (AllMembersUnloaded == true)
AQuadrilha[Quadrilha][QuadrilhaStep] = 3;
}
case 3:
{
new Float1, Float:y1, Float2, Float:y2, Floatistance, Message[128], Payment, Bonus, NumMembers, Name[24], BonusMsg[128];
NumMembers = Quadrilha_CountMembers(Quadrilha);
GetPlayerName(LeaderID, Name, sizeof(Name));
x1 = ALocations[APlayerData[LeaderID][JobLoc1]][LocX];
y1 = ALocations[APlayerData[LeaderID][JobLoc1]][LocY];
x2 = ALocations[APlayerData[LeaderID][JobLoc2]][LocX];
y2 = ALocations[APlayerData[LeaderID][JobLoc2]][LocY];
Distance = floatsqroot(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
Payment = floatround((Distance * ALoads[APlayerData[LeaderID][LoadID]][PayPerUnit]), floatround_floor);
if (RandomBonusMission[MissionFinished] == false)
{
if (RandomBonusMission[RandomLoad] == APlayerData[LeaderID][LoadID])
if (RandomBonusMission[RandomStartLoc] == APlayerData[LeaderID][JobLoc1])
if (RandomBonusMission[RandomEndLoc] == APlayerData[LeaderID][JobLoc2])
{
Payment = Payment * 3;
RandomBonusMission[MissionFinished] = true;
format(BonusMsg, 128, "{00BBFF}A Quadrilha do lнder {FFBB00}%s{00BBFF} finalizou a missгo bonus.", Name);
SendClientMessageToAll(0xFFFFFFFF, BonusMsg);
}
}
Bonus = (NumMembers * 25) + 100;
Payment = (Payment * Bonus) / 100;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
RewardPlayer(MemberID, Payment * 3, 6);
APlayerData[MemberID][StatsQuadrilhaJobs]++;
PlayerFile_Save(MemberID);
Trucker_EndJob(MemberID);
format(Message, 128, TXT_FinishQuadrilha, Payment);
SendClientMessage(MemberID, 0xFFFFFFFF, Message);
if (i != 0)
TextDrawSetString(APlayerData[MemberID][MissionText], TXT_WaitingLeaderJob);
}
}
AQuadrilha[Quadrilha][LoadID] = 0;
AQuadrilha[Quadrilha][Location1] = 0;
AQuadrilha[Quadrilha][Location2] = 0;
AQuadrilha[Quadrilha][Status] = QUADRILHA_OPEN;
AQuadrilha[Quadrilha][QuadrilhaStep] = 0;
AQuadrilha[Quadrilha][TrailerModel] = 0;
AQuadrilha[Quadrilha][LeaderInformedTrailers] = false;
}
}
return 1;
}
Quadrilha_UpdateTextDraws(Quadrilha)
{
new LeaderID, MemberID, LeaderName[24], NumMembers, TextLeader[128], TextMember[128], LastMember[24], LastMemberID, Floatistance;
LeaderID = AQuadrilha[Quadrilha][Members][0];
GetPlayerName(LeaderID, LeaderName, sizeof(LeaderName));
NumMembers = Quadrilha_CountMembers(Quadrilha);
if (NumMembers > 1)
{
LastMemberID = Quadrilha_GetFurthestMember(Quadrilha);
GetPlayerName(LastMemberID, LastMember, sizeof(LastMember));
Distance = PlayerToPlayerQ(LeaderID, LastMemberID);
}
else
{
format(LastMember, 24, " - ");
Distance = 0.0;
}
format(TextLeader, 128, TXT_LeaderInfoBar, NumMembers, LastMember, Distance);
TextDrawSetString(AQuadrilha[Quadrilha][QuadrilhaTextLeader], TextLeader);
TextDrawShowForPlayer(LeaderID, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
Distance = PlayerToPlayerQ(LeaderID, MemberID);
format(TextMember, 128, TXT_MemberInfoBar, LeaderName, Distance, NumMembers);
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 3);
TextDrawSetString(AQuadrilha[Quadrilha][QuadrilhaTextMember], TextMember);
TextDrawShowForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
}
}
}
Quadrilha_CountMembers(Quadrilha)
{
new NumMembers;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] != -1)
NumMembers++;
}
return NumMembers;
}
Quadrilha_PlayerAllowed(playerid)
{
if (APlayerData[playerid][PlayerClass] == ClassMafia)
{
if (APlayerData[playerid][InQuadrilha] == false)
{
if (APlayerData[playerid][JobStarted] == false)
return true;
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_TrabalhoJaIniciado);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaAllreadyJoined);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaNeedsMafiaClass);
return false;
}
Quadrilha_SendMessage(Quadrilha, Message[])
{
new MemberID;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
SendClientMessage(MemberID, 0xFFFFFFFF, Message);
}
}
}
stock Quadrilha_IsLeader(playerid, Quadrilha)
{
if ((APlayerData[playerid][InQuadrilha] == true) && (AQuadrilha[Quadrilha][Members][0] = playerid))
return true;
else
return false;
}
stock Quadrilha_IsMember(playerid, Quadrilha)
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
if (AQuadrilha[Quadrilha][Members][i] == playerid)
return true;
return false;
}
Quadrilha_GetFurthestMember(Quadrilha)
{
new Float:distance = 0.0, Float:distance2 = 0.0, LeaderID, MemberID, result = -1;
LeaderID = AQuadrilha[Quadrilha][Members][0];
for(new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
distance2 = PlayerToPlayerQ(LeaderID, MemberID);
if(distance2 > distance)
{
distance = distance2;
result = MemberID;
}
}
}
return result;
}
PlayerToPlayerQ(player1, player2)
{
new FloatX, FloatY, FloatZ, Float:cX, Float:cY, Float:cZ, Float:distance;
GetPlayerPos(player1, pX, pY, pZ);
GetPlayerPos(player2, cX, cY, cZ);
distance = floatsqroot(floatpower(floatabs(floatsub(cX, pX)), 2) + floatpower(floatabs(floatsub(cY, pY)), 2) + floatpower(floatabs(floatsub(cZ, pZ)), 2));
return floatround(distance);
}
//-------------------------------------------------------------------------------------------------------\\
forward Quadrilha_Timer(Quadrilha);
Quadrilha_Init()
{
for (new i; i < MAX_QUADRILHAS; i++)
{
AQuadrilha[i][QuadrilhaTextLeader] = TextDrawCreate(320.0, 1.0, " ");
TextDrawFont(AQuadrilha[i][QuadrilhaTextLeader], 2);
TextDrawLetterSize(AQuadrilha[i][QuadrilhaTextLeader], 0.399999,1.00000);
TextDrawSetShadow(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawAlignment(AQuadrilha[i][QuadrilhaTextLeader], 2);
TextDrawUseBox(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawBoxColor(AQuadrilha[i][QuadrilhaTextLeader] ,0x00000066);
AQuadrilha[i][QuadrilhaTextMember] = TextDrawCreate(320.0, 1.0, " ");
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 2);
TextDrawLetterSize(AQuadrilha[i][QuadrilhaTextMember], 0.399999,1.00000);
TextDrawSetShadow(AQuadrilha[i][QuadrilhaTextLeader], 1);
TextDrawAlignment(AQuadrilha[i][QuadrilhaTextMember], 2);
TextDrawUseBox(AQuadrilha[i][QuadrilhaTextMember], 1);
TextDrawBoxColor(AQuadrilha[i][QuadrilhaTextMember] ,0x00000066);
}
}
Quadrilha_Create(playerid, Quadrilha)
{
new Name[24], Msg[128];
GetPlayerName(playerid, Name, sizeof(Name));
if (Quadrilha_PlayerAllowed(playerid))
{
AQuadrilha[Quadrilha][Status] = QUADRILHA_OPEN;
AQuadrilha[Quadrilha][Members][0] = playerid;
APlayerData[playerid][InQuadrilha] = true;
APlayerData[playerid][QuadrilhaID] = Quadrilha;
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
AQuadrilha[Quadrilha][Members][i] = -1;
AQuadrilha[Quadrilha][QuadrilhaTimer] = SetTimerEx("Quadrilha_Timer", 1000, true, "i", Quadrilha);
format(Msg, 128, TXT_PlayerStartsQuadrilha, Name);
SendClientMessageToAll(0xFFFFFFFF, Msg);
}
}
Quadrilha_Join(playerid, Quadrilha)
{
new Name[24], Msg[128];
GetPlayerName(playerid, Name, sizeof(Name));
if (Quadrilha_PlayerAllowed(playerid))
{
if (Quadrilha_CountMembers(Quadrilha) < QUADRILHA_MAX_MEMBERS)
{
format(Msg, 128, TXT_PlayerJoinedQuadrilha, Name);
Quadrilha_SendMessage(Quadrilha, Msg);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_YouJoinedQuadrilha);
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] == -1)
{
AQuadrilha[Quadrilha][Members][i] = playerid;
break;
}
}
APlayerData[playerid][InQuadrilha] = true;
APlayerData[playerid][QuadrilhaID] = Quadrilha;
if (Quadrilha_CountMembers(Quadrilha) == QUADRILHA_MAX_MEMBERS)
AQuadrilha[Quadrilha][Status] = QUADRILHA_FULL;
TextDrawSetString(APlayerData[playerid][MissionText], TXT_WaitingLeaderJobQuadrilha);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaCheia);
}
}
Quadrilha_Leave(playerid)
{
new Quadrilha, NumMembers, MemberID;
if (APlayerData[playerid][InQuadrilha] == false)
return 1;
Quadrilha = APlayerData[playerid][QuadrilhaID];
NumMembers = Quadrilha_CountMembers(Quadrilha);
if (NumMembers == 1)
{
Quadrilha_Cancel(Quadrilha);
return 1;
}
APlayerData[playerid][InQuadrilha] = false;
APlayerData[playerid][QuadrilhaID] = 0;
TextDrawHideForPlayer(playerid, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
TextDrawHideForPlayer(playerid, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
if (APlayerData[playerid][JobStarted] == false)
TextDrawSetString(APlayerData[playerid][MissionText], Mafia_NoJobText);
if (AQuadrilha[Quadrilha][Members][0] == playerid)
{
for (new j = 1; j < QUADRILHA_MAX_MEMBERS; j++)
{
MemberID = AQuadrilha[Quadrilha][Members][j];
if (MemberID != -1)
{
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
AQuadrilha[Quadrilha][Members][0] = MemberID;
AQuadrilha[Quadrilha][Members][j] = -1;
return 1;
}
}
}
else
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] == playerid)
{
AQuadrilha[Quadrilha][Members][i] = -1;
Mafia_EndJob(playerid);
return 1;
}
}
}
return 1;
}
Quadrilha_Cancel(Quadrilha)
{
new MemberID;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
APlayerData[MemberID][InQuadrilha] = false;
APlayerData[MemberID][QuadrilhaID] = 0;
TextDrawFont(AQuadrilha[i][QuadrilhaTextLeader], 3);
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 3);
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
TextDrawHideForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
Mafia_EndJob(MemberID);
AQuadrilha[Quadrilha][Members][i] = -1;
SendClientMessage(MemberID, 0xFFFFFFFF, TXT_LeaderCancelledQuadrilha);
}
}
AQuadrilha[Quadrilha][LoadID] = 0;
AQuadrilha[Quadrilha][Location1] = 0;
AQuadrilha[Quadrilha][Location2] = 0;
AQuadrilha[Quadrilha][Status] = QUADRILHA_EMPTY;
AQuadrilha[Quadrilha][QuadrilhaStep] = 0;
KillTimer(AQuadrilha[Quadrilha][QuadrilhaTimer]);
}
Quadrilha_StartMemberJob(playerid, Quadrilha)
{
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float, Float:y, Float:z, LoadMsg[128];
APlayerData[playerid][JobStarted] = true;
APlayerData[playerid][LoadID] = AQuadrilha[Quadrilha][LoadID];
APlayerData[playerid][JobLoc1] = AQuadrilha[Quadrilha][Location1];
APlayerData[playerid][JobLoc2] = AQuadrilha[Quadrilha][Location2];
APlayerData[playerid][VehicleID] = GetPlayerVehicleID(playerid);
APlayerData[playerid][JobStep] = 1;
format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
format(RouteText, 255, TXT_HaulingCargoFromToPickup, Load, StartLoc, EndLoc);
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
x = ALocations[APlayerData[playerid][JobLoc1]][LocX];
y = ALocations[APlayerData[playerid][JobLoc1]][LocY];
z = ALocations[APlayerData[playerid][JobLoc1]][LocZ];
SetPlayerCheckpoint(playerid, x, y, z, 7);
APlayerData[playerid][VehicleTimerTime] = Job_TimeToFailMission;
format(LoadMsg, 128, TXT_PickupCargoAt, Load, StartLoc);
SendClientMessage(playerid, 0xFFFFFFFF, LoadMsg);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_MeetOtherQuadrilhaMembers);
}
Quadrilha_UpdateMemberJob(playerid)
{
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float, Float:y, Float:z, UnloadMsg[128];
APlayerData[playerid][JobStep] = 3;
format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
format(RouteText, 255, TXT_HaulingCargoFromToDeliver, Load, StartLoc, EndLoc);
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
x = ALocations[APlayerData[playerid][JobLoc2]][LocX];
y = ALocations[APlayerData[playerid][JobLoc2]][LocY];
z = ALocations[APlayerData[playerid][JobLoc2]][LocZ];
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(UnloadMsg, 128, TXT_DeliverCargoTo, Load, EndLoc);
SendClientMessage(playerid, 0xFFFFFFFF, UnloadMsg);
}
public Quadrilha_Timer(Quadrilha)
{
new LeaderID, MemberID;
Quadrilha_UpdateTextDraws(Quadrilha);
LeaderID = AQuadrilha[Quadrilha][Members][0];
switch (AQuadrilha[Quadrilha][QuadrilhaStep])
{
case 0:
{
new bool:AllSameTrailer = true;
if (APlayerData[LeaderID][JobStarted] == true)
{
AQuadrilha[Quadrilha][LoadID] = APlayerData[LeaderID][LoadID];
AQuadrilha[Quadrilha][Location1] = APlayerData[LeaderID][JobLoc1];
AQuadrilha[Quadrilha][Location2] = APlayerData[LeaderID][JobLoc2];
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
new vModel = GetVehicleModel(GetPlayerVehicleID(MemberID));
switch (vModel)
{
case VehicleSandKing, VehicleMoonbeam: AllSameTrailer = true;
default:
{
TextDrawSetString(APlayerData[MemberID][MissionText], "Vocк precisa de um SandKing ou Moombeam");
AllSameTrailer = false;
}
}
}
}
}
if (AllSameTrailer == true)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersSameVehicle);
for (new i = 1; i <QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
Quadrilha_StartMemberJob(MemberID, Quadrilha);
}
AQuadrilha[Quadrilha][QuadrilhaStep] = 1;
AQuadrilha[Quadrilha][Status] = QUADRILHA_CLOSED;
}
else
{
if (AQuadrilha[Quadrilha][LeaderInformedTrailers] == false)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersNotVehicle);
AQuadrilha[Quadrilha][LeaderInformedTrailers] = true;
}
}
}
}
case 1:
{
new bool:AllMembersLoaded = true;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
if (APlayerData[MemberID][JobStep] != 2)
AllMembersLoaded = false;
}
if (AllMembersLoaded == true)
{
SendClientMessage(LeaderID, 0xFFFFFFFF, TXT_AllMembersCarregados);
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
Quadrilha_UpdateMemberJob(MemberID);
}
AQuadrilha[Quadrilha][QuadrilhaStep] = 2;
}
}
case 2:
{
new bool:AllMembersUnloaded = true;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
if (APlayerData[MemberID][JobStep] != 4)
AllMembersUnloaded = false;
}
if (AllMembersUnloaded == true)
AQuadrilha[Quadrilha][QuadrilhaStep] = 3;
}
case 3:
{
new Float1, Float:y1, Float2, Float:y2, Floatistance, Message[128], Payment, Bonus, NumMembers, Name[24], BonusMsg[128];
NumMembers = Quadrilha_CountMembers(Quadrilha);
GetPlayerName(LeaderID, Name, sizeof(Name));
x1 = ALocations[APlayerData[LeaderID][JobLoc1]][LocX];
y1 = ALocations[APlayerData[LeaderID][JobLoc1]][LocY];
x2 = ALocations[APlayerData[LeaderID][JobLoc2]][LocX];
y2 = ALocations[APlayerData[LeaderID][JobLoc2]][LocY];
Distance = floatsqroot(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
Payment = floatround((Distance * ALoads[APlayerData[LeaderID][LoadID]][PayPerUnit]), floatround_floor);
if (RandomBonusMission[MissionFinished] == false)
{
if (RandomBonusMission[RandomLoad] == APlayerData[LeaderID][LoadID])
if (RandomBonusMission[RandomStartLoc] == APlayerData[LeaderID][JobLoc1])
if (RandomBonusMission[RandomEndLoc] == APlayerData[LeaderID][JobLoc2])
{
Payment = Payment * 3;
RandomBonusMission[MissionFinished] = true;
format(BonusMsg, 128, "{00BBFF}A Quadrilha do lнder {FFBB00}%s{00BBFF} finalizou a missгo bonus.", Name);
SendClientMessageToAll(0xFFFFFFFF, BonusMsg);
}
}
Bonus = (NumMembers * 25) + 100;
Payment = (Payment * Bonus) / 100;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
RewardPlayer(MemberID, Payment * 3, 6);
APlayerData[MemberID][StatsQuadrilhaJobs]++;
PlayerFile_Save(MemberID);
Trucker_EndJob(MemberID);
format(Message, 128, TXT_FinishQuadrilha, Payment);
SendClientMessage(MemberID, 0xFFFFFFFF, Message);
if (i != 0)
TextDrawSetString(APlayerData[MemberID][MissionText], TXT_WaitingLeaderJob);
}
}
AQuadrilha[Quadrilha][LoadID] = 0;
AQuadrilha[Quadrilha][Location1] = 0;
AQuadrilha[Quadrilha][Location2] = 0;
AQuadrilha[Quadrilha][Status] = QUADRILHA_OPEN;
AQuadrilha[Quadrilha][QuadrilhaStep] = 0;
AQuadrilha[Quadrilha][TrailerModel] = 0;
AQuadrilha[Quadrilha][LeaderInformedTrailers] = false;
}
}
return 1;
}
Quadrilha_UpdateTextDraws(Quadrilha)
{
new LeaderID, MemberID, LeaderName[24], NumMembers, TextLeader[128], TextMember[128], LastMember[24], LastMemberID, Floatistance;
LeaderID = AQuadrilha[Quadrilha][Members][0];
GetPlayerName(LeaderID, LeaderName, sizeof(LeaderName));
NumMembers = Quadrilha_CountMembers(Quadrilha);
if (NumMembers > 1)
{
LastMemberID = Quadrilha_GetFurthestMember(Quadrilha);
GetPlayerName(LastMemberID, LastMember, sizeof(LastMember));
Distance = PlayerToPlayerQ(LeaderID, LastMemberID);
}
else
{
format(LastMember, 24, " - ");
Distance = 0.0;
}
format(TextLeader, 128, TXT_LeaderInfoBar, NumMembers, LastMember, Distance);
TextDrawSetString(AQuadrilha[Quadrilha][QuadrilhaTextLeader], TextLeader);
TextDrawShowForPlayer(LeaderID, AQuadrilha[Quadrilha][QuadrilhaTextLeader]);
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
Distance = PlayerToPlayerQ(LeaderID, MemberID);
format(TextMember, 128, TXT_MemberInfoBar, LeaderName, Distance, NumMembers);
TextDrawFont(AQuadrilha[i][QuadrilhaTextMember], 3);
TextDrawSetString(AQuadrilha[Quadrilha][QuadrilhaTextMember], TextMember);
TextDrawShowForPlayer(MemberID, AQuadrilha[Quadrilha][QuadrilhaTextMember]);
}
}
}
Quadrilha_CountMembers(Quadrilha)
{
new NumMembers;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
if (AQuadrilha[Quadrilha][Members][i] != -1)
NumMembers++;
}
return NumMembers;
}
Quadrilha_PlayerAllowed(playerid)
{
if (APlayerData[playerid][PlayerClass] == ClassMafia)
{
if (APlayerData[playerid][InQuadrilha] == false)
{
if (APlayerData[playerid][JobStarted] == false)
return true;
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_TrabalhoJaIniciado);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaAllreadyJoined);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_QuadrilhaNeedsMafiaClass);
return false;
}
Quadrilha_SendMessage(Quadrilha, Message[])
{
new MemberID;
for (new i; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
SendClientMessage(MemberID, 0xFFFFFFFF, Message);
}
}
}
stock Quadrilha_IsLeader(playerid, Quadrilha)
{
if ((APlayerData[playerid][InQuadrilha] == true) && (AQuadrilha[Quadrilha][Members][0] = playerid))
return true;
else
return false;
}
stock Quadrilha_IsMember(playerid, Quadrilha)
{
for (new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
if (AQuadrilha[Quadrilha][Members][i] == playerid)
return true;
return false;
}
Quadrilha_GetFurthestMember(Quadrilha)
{
new Float:distance = 0.0, Float:distance2 = 0.0, LeaderID, MemberID, result = -1;
LeaderID = AQuadrilha[Quadrilha][Members][0];
for(new i = 1; i < QUADRILHA_MAX_MEMBERS; i++)
{
MemberID = AQuadrilha[Quadrilha][Members][i];
if (MemberID != -1)
{
distance2 = PlayerToPlayerQ(LeaderID, MemberID);
if(distance2 > distance)
{
distance = distance2;
result = MemberID;
}
}
}
return result;
}
PlayerToPlayerQ(player1, player2)
{
new FloatX, FloatY, FloatZ, Float:cX, Float:cY, Float:cZ, Float:distance;
GetPlayerPos(player1, pX, pY, pZ);
GetPlayerPos(player2, cX, cY, cZ);
distance = floatsqroot(floatpower(floatabs(floatsub(cX, pX)), 2) + floatpower(floatabs(floatsub(cY, pY)), 2) + floatpower(floatabs(floatsub(cZ, pZ)), 2));
return floatround(distance);
}