12.09.2016, 07:25
(
Последний раз редактировалось JordanZaundd; 14.09.2016 в 22:24.
Причина: Had wrong variable in for loop
)
If you add the include uf.inc, you can use some of the functions to help you.
PHP код:
#include <uf> // Don't forget to declare the include
//Make sure to change the variables accordingly, this is only a template.
//Place this in the function you use to generate bills.
for(new i = 0; i < MAX_GANGS; i++) // Creates for loop to see any gang is nearby.
{
if(IsHouseInRangeOfGang(HouseInfo[i], 30.0) // Get the HouseID you want checked if it is in range of any gangs.
{
new string[64]; // Create a string to store the message being sent to the player.
HouseInfo[i][hTax] += 100; // Sets the house's tax to be $100.00 more than it should because a gang is in the area.
format(string, sizeof(string), "You have paid an extra $100 to %s as a protection fee.", GetNearbyGangName(hID, 30.0); // Formats string to notify player it paid a protection fee to said gang.
SendClientMessage(playerid, COLOR_LIGHTRED, string); // Sends the formatting string.
}
}
//Now we have to create the functions we just used.
public IsHouseInRangeOfGang(hID, Float:range) // Create IsHouseInRangeOfGang.
{
for(new i = 0; i < MAX_GANGS; i++) // Create loop so it will search to see if any gang is within range.
{
new Float:gRange = GetPointDistanceToPointEx(HouseInfo[hID][hPosX], HouseInfo[hID][hPosY], HouseInfo[hID][hPosZ], GangInfo[i][gPosX], GangInfo[i][gPosY], GangInfo[i][gPosZ]);
if(gRange < range) // Calculates range then compares to see if within specified range.
return 1; // Tells the script that there is a nearby gang.
}
return 0; // Lets the script know there was no nearby gangs in the area.
}
forward IsHouseInRangeOfGang(hID, Float:range);
stock GetNearbyGangName(hID, Float:range) // Create GetNearbyGangName - It's a stock because it's returning a string.
{
new gangName[32], Float:gRange;
for(new i = 0; i < MAX_GANGS; i++) // Create loop like InHouseInRangeOfGang except returns gang name instead of 1 or 0.
{
gRange = GetPointDistanceToPointEx(HouseInfo[hID][hPosX], HouseInfo[houseID][hPosY], HouseInfo[houseID][pPosZ], GangInfo[i][gPosX], GangInfo[i][gPosY], GangInfo[i][gPosZ]);
if(gRange < range) // Calculates range then compares to see if within the specified range.
gangName = GangInfo[i][gName]; // Sets variable to gang's name
}
return gangName; // Returns the gangs name to where the stock was called.
}