Simple problem
#3

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 0MAX_GANGSi++) // 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(stringsizeof(string), "You have paid an extra $100 to %s as a protection fee."GetNearbyGangName(hID30.0); // Formats string to notify player it paid a protection fee to said gang.
        
SendClientMessage(playeridCOLOR_LIGHTREDstring); // Sends the formatting string.
    
}
}
//Now we have to create the functions we just used.
public IsHouseInRangeOfGang(hIDFloat:range// Create IsHouseInRangeOfGang.
{
    for(new 
0MAX_GANGSi++) // 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(hIDFloat:range);
stock GetNearbyGangName(hIDFloat:range// Create GetNearbyGangName - It's a stock because it's returning a string.
{
    new 
gangName[32], Float:gRange;
    for(new 
0MAX_GANGSi++) // 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.

Reply


Messages In This Thread
Simple problem - by StR_MaRy - 12.09.2016, 01:28
Re: Simple problem - by Logic_ - 12.09.2016, 05:54
Re: Simple problem - by JordanZaundd - 12.09.2016, 07:25
Re: Simple problem - by StR_MaRy - 12.09.2016, 11:30

Forum Jump:


Users browsing this thread: 2 Guest(s)