Simple problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple problem (
/showthread.php?tid=616892)
Simple problem -
StR_MaRy - 12.09.2016
hey guys is possible if i want to put 2-3 houses near to a gang HQ to pay more on every hour ? like a protection fee ? can some1 help me out with something?
like house with id: 100,101,102 to pay 100$ more at every bill
Re: Simple problem -
Logic_ - 12.09.2016
Yea, show us your code where you generate the bills for them and the gang hq stuff.
This forum requires that you wait 120 seconds between posts. Please try again in 22 seconds. -_-
Re: Simple problem -
JordanZaundd - 12.09.2016
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.
}
Re: Simple problem -
StR_MaRy - 12.09.2016
thx verry much it works