PDA

View Full Version : Pickups.


iGetty
12/06/2012, 06:13 PM
I have a problem with my pickups.

The house pickups show perfectly, but when it comes to business pickups, they don't work at all.

Can anyone help me please? Code is below.

public PickupMessages(playerid)
{
new string[512];
for(new h = 1; h < MAX_HOUSES; h++)
{
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(IsPlayerInRangeOfPoint(playerid, 2.0, Houses[h][HouseExteriorX], Houses[h][HouseExteriorY], Houses[h][HouseExteriorZ]))
{
if(GetPlayerVirtualWorld(playerid) == 0)
{
if(strmatch(Houses[h][HouseOwner], "Nobody"))
{
if(Player[playerid][AdminLevel] == 10)
{
format(string, sizeof(string), "~w~House %d~n~~b~%s~n~~w~Use ~b~/buyhouse~w~ to~n~buy this house~n~for ~g~$%d.", h, Houses[h][HouseName], Houses[h][HousePrice]);
}
else
{
format(string, sizeof(string), "~b~%s~n~~w~Use ~b~/buyhouse~w~ to~n~buy this house~n~for ~g~$%d.", Houses[h][HouseName], Houses[h][HousePrice]);
}
}
else
{
if(Player[playerid][AdminLevel] == 10)
{
format(string, sizeof(string), "~w~House %d~n~~b~%s~n~~w~Owner:~g~ %s", h, Houses[h][HouseName], Houses[h][HouseOwner]);
}
else
{
format(string, sizeof(string), "~b~%s~n~~w~Owner:~g~ %s", Houses[h][HouseName], Houses[h][HouseOwner]);
}
}
}
}
}
for(new b = 1; b < MAX_BUSINESS; b++)
{
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(IsPlayerInRangeOfPoint(playerid, 2.0, Business[b][BusinessExteriorX], Business[b][BusinessExteriorY], Business[b][BusinessExteriorZ]))
{
if(GetPlayerVirtualWorld(playerid) == 0)
{
if(Player[playerid][AdminLevel] == 10)
{
format(string, sizeof(string), "~w~Business %d~n~~b~%s~n~~w~~n~Owner:~g~ %s~n~~w~Enter Fee: ~g~$%d~n~~w~~n~Type /enter to go inside", b, Business[b][BusinessName], Business[b][BusinessOwner], Business[b][BusinessEnterFee]);
}
else
{
format(string, sizeof(string), "~w~Business~n~~b~%s~n~~w~~n~Owner:~g~ %s~n~~w~Enter Fee: ~g~$%d~n~~w~~n~Type /enter to go inside", Business[b][BusinessName], Business[b][BusinessOwner], Business[b][BusinessEnterFee]);
}
}
}
}
GameTextForPlayer(playerid, string, 3000, 5);
return 1;
}

Thanks!

iggy1
12/06/2012, 06:19 PM
Have you added some prints to see where it stops working?

iGetty
12/06/2012, 06:19 PM
I'll do that now and edit this.

iGetty
12/06/2012, 06:34 PM
I added prints and it seems to stop on the line:

if(IsPlayerInRangeOfPoint(playerid, 2.0, Business[b][BusinessExteriorX], Business[b][BusinessExteriorY], Business[b][BusinessExteriorZ]))

Even though I'm in range of it.

iggy1
12/06/2012, 06:36 PM
There must be a problem with the co-ordinates saved in the "Business" var.

A quick way to test is to teleport yourself to that location, that way you know instantly if your co-ordinates are mixed up.

iGetty
12/06/2012, 06:39 PM
How could I do that? Like, create a /gotobusiness command with the business ID in sscanf?

Then, check if it's letting me go to it? :3

WillyP
12/06/2012, 06:41 PM
How could I do that? Like, create a /gotobusiness command with the business ID in sscanf?

Then, check if it's letting me go to it? :3

Use the co-ordinates from the Business file, and IG teleport yourself to those exact co-ordinates to see if they are accurate.

iggy1
12/06/2012, 06:46 PM
Params is the index for your buisness.

COMMAND:tp(playerid, params[])
{
new idx = strval(params);

if( idx > -1 && idx < sizeof(Business) )
{
SetPlayerPos(playerid, Business[idx][BusinessExteriorX], Business[idx][BusinessExteriorY], Business[idx][BusinessExteriorZ]);
}
return 1;
}

iGetty
12/06/2012, 06:48 PM
Found the problem.. It seems to only let me go to ID 1..

No more than 1, or I'm falling in blueberry... What's wrong?

Here's my LoadBusinesses();

stock LoadBusinesses()
{
new
Str[128],
string[512],
bID,
bName[128],
bOwner[24],
Float:ExtX,
Float:ExtY,
Float:ExtZ,
Float:IntX,
Float:IntY,
Float:IntZ,
Price,
Enterable,
IntID,
Fee,
PayOut,
Locked,
World;

mysql_query("SELECT * FROM `Businesses`");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Str))
{
sscanf(Str, "p<|>is[128]s[24]ffffffiiiiiii", bID, bName, bOwner, ExtX, ExtY, ExtZ, IntX, IntY, IntZ, IntID, Price, Enterable, Fee, PayOut, Locked, World);
BusinessPickup[bID] = CreatePickup(1272, 1, ExtX, ExtY, ExtZ, 0);
new i = 1;
Business[i][BusinessExteriorX] = ExtX;
Business[i][BusinessExteriorY] = ExtY;
Business[i][BusinessExteriorZ] = ExtZ;
Business[i][BusinessInteriorX] = IntX;
Business[i][BusinessInteriorY] = IntY;
Business[i][BusinessInteriorZ] = IntZ;
Business[i][BusinessInteriorID] = IntID;
Business[i][BusinessPrice] = Price;
Business[i][BusinessEnterable] = Enterable;
Business[i][BusinessEnterFee] = Fee;
Business[i][BusinessPayout] = PayOut;
Business[i][BusinessLocked] = Locked;
Business[i][BusinessWorld] = World;
format(Business[i][BusinessName], 128, "%s", bName);
format(Business[i][BusinessOwner], 24, "%s", bOwner);
if(Enterable == 0)
{
format(string, sizeof(string), "{FF0000}%s\nOwner:{FFFFFF}%s\n{FF0000}Payout: {FFFFFF}$%d", bName, bOwner, PayOut);
}
else
{
format(string, sizeof(string), "{33FF33}%s\nEntrance Fee: {FFFFFF}$%d{33FF33}\nOwner: {FFFFFF}%s\n{33FF33}Payout: {FFFFFF}$%d", bName, Fee, bOwner,PayOut);
}
BusinessLabel[i] = Create3DTextLabel(string, BLUE, ExtX, ExtY, ExtZ, 7.0, 0, 1);
i++;
bTotal++;
}
}
mysql_free_result();
printf("%i businesses loaded from the MySQL Database.", bTotal);
}

It works for my houses, but not businesses.. It's also creating the business pickup and label in the correct place.

iggy1
12/06/2012, 06:50 PM
new i = 1;

Your resetting the index var to 1 every loop.

iGetty
12/06/2012, 09:35 PM
Sorry for the slow reply, I got it, thanks :D