PDA

View Full Version : Range of point help


dundolina
15/05/2015, 10:54 PM
Hello i have random checkpoints and how to add them in range of point?

new Float:RandomMoneyBoxVzimane[][3] =
{
{2227.74, 1516.43, 10.82},
{-724.44, 1402.81, 13.07},
{-1940.61, 1086.14, 53.09},
{-2344.37, -459.59, 80.01},
{-1674.65, -543.03, 14.14},
{-2415.30, -2142.08, 52.37},
{-1527.47, -2291.62, -5.63},
{-1111.05, -2470.04, 76.59},
{-288.23, -2163.67, 28.63},
{-376.27, -2583.97, 138.17},
{378.32, -1885.70, 2.05},
{1120.86, -2065.82, 74.42},
{1583.25, -2286.55, 13.53},
{2718.67, -2385.16, 13.63},
{2744.79, -1944.55, 17.32},
{2041.71, -1715.58, 13.54},
{2771.79, -1354.51, 50.00},
{1102.96, -1092.89, 28.46},
{727.73, -1276.13, 13.64},
{755.31, -591.31, 18.01},
{360.91, -110.02, 1.22},
{-557.35, -541.28, 25.52},
{-273.04, -955.98, 38.30},
{1242.36, 327.17, 19.75},
{2791.64, 2225.64, 14.66},
{-1955.01, -986.97, 35.89},
{-2108.89, -2376.97, 30.62},
{1853.35, 2045.54, 10.85},
{2478.85, -1437.22, 25.49},
{-2241.50, 2462.93, 4.98},
{703.36, 267.78, 21.44},
{-599.09, -1080.95, 23.66},
{-2677.68, 1503.98, 2.07},
{2582.18, -2115.22, 1.11},
{-1954.97, -986.27, 35.89},
{541.41, 830.33, -39.44},
{-2876.66, 292.77, 6.96},
{-2192.16, 2409.51, 4.95},
{2615.91, -1730.39, 6.24},
{-529.81, -991.29, 24.55},
{-1048.33, -1306.72, 128.50},
{1227.20, 2584.68, 10.82},
{1016.48, 1411.63, 10.82},
{-1593.62, 802.54, 6.82},
{-2238.23, -2478.96, 31.19},
{917.43, 2402.92, 10.82},
{1312.97, -1965.60, 29.46},
{-120.59, -1531.31, 3.07},
{-2508.68, -53.19, 25.65},
{-2762.04, 105.18, 6.99},
{1367.53, 194.54, 19.55},
{-2655.83, -102.70, 3.99},
{2161.85, -102.76, 2.75},
{2535.77, 1342.55, 10.82},
{-2059.10, 890.89, 61.85},
{1188.14, 231.38, 19.56},
{1088.81, 1073.79, 10.83},
{422.96, 2539.45, 16.52},
{-227.49, 2709.91, 62.98},
{-347.38, 1581.21, 76.30},
{-208.08, 1127.93, 19.74},
{33.24, 1155.21, 19.69},
{1582.07, -2691.56, 6.12},
{1715.25, -1912.01, 13.56},
{286.36, -1145.15, 80.91}
};

if (IsPlayerInRangeOfPoint(playerid, 3.0,MB1))
{
PlayerInfo[playerid][pKufar] = 1;
Kufar = 1;
Moneybox = 0;
format(string2, sizeof(string2), "Moneybox: %s взе куфара!",PlayerName(playerid));
SendClientMessageToAll(COLOR_GREEN, string2);
SendClientMessage(playerid,COLOR_GREEN,"Ти взе куфара сега трябва да го доставиш!");
DisablePlayerCheckpoint(i);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(i, MB2, 3.0);
SetPlayerCheckpoint(playerid, MB2, 3.0);

}

JaydenJason
15/05/2015, 11:05 PM
1st off your indenting, what the hell

IsPlayerInRangeOfPoint(playerid, 3.0,MB1)
mb1? what is that even supposed to mean
mb2? ...
unless you have it defined put it in here

and in which callback is that placed?

edit: might want to look at this

https://wiki.sa-mp.com/wiki/SetPlayerRaceCheckpoint

Abagail
15/05/2015, 11:29 PM
IsPlayerInRangeOfPoint(playerid, 3.0,MB1)
mb1? what is that even supposed to mean
mb2? ...
edit: might want to look at this



#define mb2 0, 0, 0
Nothing wrong with it, as the define will simply replace the text assuming this is how he defines mb2.

Luis-
15/05/2015, 11:31 PM
Would be nice to see the mb1 define if you do have one.

dundolina
15/05/2015, 11:44 PM
I want to replace this MB1 with this all checkpoints. MB1 is just one of them.

dundolina
16/05/2015, 08:17 AM
Help?

Smileys
16/05/2015, 08:20 AM
I'll help ya when I get on my pc.

Logofero
16/05/2015, 09:08 AM
new Float:RandomMoneyBoxVzimane[][3] =
{
{2227.74, 1516.43, 10.82},
{-724.44, 1402.81, 13.07},
{-1940.61, 1086.14, 53.09},
{-2344.37, -459.59, 80.01},
{-1674.65, -543.03, 14.14},
{-2415.30, -2142.08, 52.37},
{-1527.47, -2291.62, -5.63},
{-1111.05, -2470.04, 76.59},
{-288.23, -2163.67, 28.63},
{-376.27, -2583.97, 138.17},
{378.32, -1885.70, 2.05},
{1120.86, -2065.82, 74.42},
{1583.25, -2286.55, 13.53},
{2718.67, -2385.16, 13.63},
{2744.79, -1944.55, 17.32},
{2041.71, -1715.58, 13.54},
{2771.79, -1354.51, 50.00},
{1102.96, -1092.89, 28.46},
{727.73, -1276.13, 13.64},
{755.31, -591.31, 18.01},
{360.91, -110.02, 1.22},
{-557.35, -541.28, 25.52},
{-273.04, -955.98, 38.30},
{1242.36, 327.17, 19.75},
{2791.64, 2225.64, 14.66},
{-1955.01, -986.97, 35.89},
{-2108.89, -2376.97, 30.62},
{1853.35, 2045.54, 10.85},
{2478.85, -1437.22, 25.49},
{-2241.50, 2462.93, 4.98},
{703.36, 267.78, 21.44},
{-599.09, -1080.95, 23.66},
{-2677.68, 1503.98, 2.07},
{2582.18, -2115.22, 1.11},
{-1954.97, -986.27, 35.89},
{541.41, 830.33, -39.44},
{-2876.66, 292.77, 6.96},
{-2192.16, 2409.51, 4.95},
{2615.91, -1730.39, 6.24},
{-529.81, -991.29, 24.55},
{-1048.33, -1306.72, 128.50},
{1227.20, 2584.68, 10.82},
{1016.48, 1411.63, 10.82},
{-1593.62, 802.54, 6.82},
{-2238.23, -2478.96, 31.19},
{917.43, 2402.92, 10.82},
{1312.97, -1965.60, 29.46},
{-120.59, -1531.31, 3.07},
{-2508.68, -53.19, 25.65},
{-2762.04, 105.18, 6.99},
{1367.53, 194.54, 19.55},
{-2655.83, -102.70, 3.99},
{2161.85, -102.76, 2.75},
{2535.77, 1342.55, 10.82},
{-2059.10, 890.89, 61.85},
{1188.14, 231.38, 19.56},
{1088.81, 1073.79, 10.83},
{422.96, 2539.45, 16.52},
{-227.49, 2709.91, 62.98},
{-347.38, 1581.21, 76.30},
{-208.08, 1127.93, 19.74},
{33.24, 1155.21, 19.69},
{1582.07, -2691.56, 6.12},
{1715.25, -1912.01, 13.56},
{286.36, -1145.15, 80.91}
};

#define MAX_RANGE_PICKUP (2.0)
new money_box[][MAX_PLAYERS];

public OnPlayerSpawn(playerid) {
for(new i, j = sizeof(RandomMoneyBoxVzimane); i < j; i++) {
money_box[i][playerid]=1; // Enable ALL money box for respaw player
}
return 1;
}

public OnPlayerUpdate(playerid) {

for(new i, j = sizeof(RandomMoneyBoxVzimane); i < j; i++) {
if (money_box[i][playerid] && IsPlayerInRangeOfPoint(playerid, MAX_RANGE_PICKUP, RandomMoneyBoxVzimane[i][0], RandomMoneyBoxVzimane[i][1], RandomMoneyBoxVzimane[i][2]))
{
money_box[i][playerid]=0; // Disable money box if pickuped

PlayerInfo[playerid][pKufar] = 1;
Kufar = 1;
Moneybox = 0;
format(string2, sizeof(string2), "Moneybox: %s взе куфара!",PlayerName(playerid));
SendClientMessageToAll(COLOR_GREEN, string2);
SendClientMessage(playerid,COLOR_GREEN,"Ти взе куфара сега трябва да го доставиш!");
break;
}
}

}

KeNTos
16/05/2015, 01:46 PM
For(new I; i< sizeof(RandomMoneyBoxVzimane); i++)
(
if (IsPlayerInRangeOfPoint(playerid, 3.0, RandomMoneyBoxVzimane[0], RandomMoneyBoxVzimane[1], RandomMoneyBoxVzimane[2]))
{
PlayerInfo[playerid][pKufar] = 1;
Kufar = 1;
Moneybox = 0;
format(string2, sizeof(string2), "Moneybox: %s âçå êóôàðà!",PlayerName(playerid));
SendClientMessageToAll(COLOR_GREEN, string2);
SendClientMessage(playerid,COLOR_GREEN,"Òè âçå êóôàðà ñåãà òðÿáâà äà ãî äîñòàâèø!");
DisablePlayerCheckpoint(i);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(i, MB2, 3.0);
SetPlayerCheckpoint(playerid, MB2, 3.0);

}
)
Еще можешь сделать break в вконце цикла, я просто до конца не понял что тебе нужно)

Logofero
16/05/2015, 02:37 PM
For(new I; i< sizeof(RandomMoneyBoxVzimane); i++)

Better one time to declare a variable than to constantly seek to call the same function
Example:
for(new i, j = sizeof(RandomMoneyBoxVzimane); i<j; i++) {
...
}

Konstantinos
16/05/2015, 02:39 PM
Better one time to declare a variable than to constantly seek to call the same function

sizeof is a constant operator.

Threshold
16/05/2015, 03:17 PM
new Float:RandomMoneyBoxVzimane[][3] =
{
{2227.74, 1516.43, 10.82}, {-724.44, 1402.81, 13.07}, {-1940.61, 1086.14, 53.09},
{-2344.37, -459.59, 80.01}, {-1674.65, -543.03, 14.14}, {-2415.30, -2142.08, 52.37},
{-1527.47, -2291.62, -5.63}, {-1111.05, -2470.04, 76.59}, {-288.23, -2163.67, 28.63},
{-376.27, -2583.97, 138.17}, {378.32, -1885.70, 2.05}, {1120.86, -2065.82, 74.42},
{1583.25, -2286.55, 13.53}, {2718.67, -2385.16, 13.63}, {2744.79, -1944.55, 17.32},
{2041.71, -1715.58, 13.54}, {2771.79, -1354.51, 50.00}, {1102.96, -1092.89, 28.46},
{727.73, -1276.13, 13.64}, {755.31, -591.31, 18.01}, {360.91, -110.02, 1.22},
{-557.35, -541.28, 25.52}, {-273.04, -955.98, 38.30}, {1242.36, 327.17, 19.75},
{2791.64, 2225.64, 14.66}, {-1955.01, -986.97, 35.89}, {-2108.89, -2376.97, 30.62},
{1853.35, 2045.54, 10.85}, {2478.85, -1437.22, 25.49}, {-2241.50, 2462.93, 4.98},
{703.36, 267.78, 21.44}, {-599.09, -1080.95, 23.66}, {-2677.68, 1503.98, 2.07},
{2582.18, -2115.22, 1.11}, {-1954.97, -986.27, 35.89}, {541.41, 830.33, -39.44},
{-2876.66, 292.77, 6.96}, {-2192.16, 2409.51, 4.95}, {2615.91, -1730.39, 6.24},
{-529.81, -991.29, 24.55}, {-1048.33, -1306.72, 128.50}, {1227.20, 2584.68, 10.82},
{1016.48, 1411.63, 10.82}, {-1593.62, 802.54, 6.82}, {-2238.23, -2478.96, 31.19},
{917.43, 2402.92, 10.82}, {1312.97, -1965.60, 29.46}, {-120.59, -1531.31, 3.07},
{-2508.68, -53.19, 25.65}, {-2762.04, 105.18, 6.99}, {1367.53, 194.54, 19.55},
{-2655.83, -102.70, 3.99}, {2161.85, -102.76, 2.75}, {2535.77, 1342.55, 10.82},
{-2059.10, 890.89, 61.85}, {1188.14, 231.38, 19.56}, {1088.81, 1073.79, 10.83},
{422.96, 2539.45, 16.52}, {-227.49, 2709.91, 62.98}, {-347.38, 1581.21, 76.30},
{-208.08, 1127.93, 19.74}, {33.24, 1155.21, 19.69}, {1582.07, -2691.56, 6.12},
{1715.25, -1912.01, 13.56}, {286.36, -1145.15, 80.91}
};

// Checking if player is in range of one of the points.
for(new i = 0; i < sizeof(RandomMoneyBoxVzimane); ++i)
{
if(!IsPlayerInRangeOfPoint(playerid, 3.0, RandomMoneyBoxVzimane[i][0], RandomMoneyBoxVzimane[i][1], RandomMoneyBoxVzimane[i][2])) continue;
// Player is in range of a point
PlayerInfo[playerid][pKufar] = 1;
Kufar = 1;
Moneybox = 0;
new fstr[48], rand = random(sizeof(RandomMoneyBoxVzimane));
format(fstr, sizeof(fstr), "Moneybox: %s взе куфара!", PlayerName(playerid));
SendClientMessageToAll(COLOR_GREEN, fstr);
SendClientMessage(playerid, COLOR_GREEN, "Ти взе куфара сега трябва да го доставиш!");
for(new x = 0, y = GetPlayerPoolSize(); x < y; ++x)
{
if(!IsPlayerConnected(x)) continue; // Foreach is a better alternative
DisablePlayerCheckpoint(x);
SetPlayerCheckpoint(x, RandomMoneyBoxVzimane[rand][0], RandomMoneyBoxVzimane[rand][1], RandomMoneyBoxVzimane[rand][2], 3.0);
}
break;
}

There are definitely much easier methods to doing this... but I'm not getting paid for this, so... you're welcome.

Logofero
16/05/2015, 04:06 PM
sizeof is a constant operator.

Please tell me is your work faster?

new msg[256];
format(msg, sizeof(msg), "I always calling to calculate the sizeof()");
or

new msg[256];
format(msg, 256, "Seriously? But why? I know the length of the text and is used");

Okay text. And if that cycle?

new array[100000];
for(new i; i < sizeof(array); i++) { //Every time he would get value for the size of the array? Whenever an iteration?
...
}
or

new array[100000];
for(new i, j=sizeof(array); i<j; i++) { //Once and constantly use
...
}

Konstantinos
16/05/2015, 04:12 PM
You still don't understand sizeof is an operator, not a function to call.

#define MAX_STH 50
static Sth[MAX_STH];
// ---
for (new i; i != sizeof (Sth); ++i)
// is exactly the same as:
for (new i; i != MAX_STH; ++i)


Having a function (custom or native by samp/plugin), then yes - do that to avoid calling a function multiply times but in the above case is not the same. As for the text, only lazy programmers avoid to use it.

Logofero
16/05/2015, 04:16 PM
You still don't understand sizeof is an operator, not a function to call.

#define MAX_STH 50
static Sth[MAX_STH];
// ---
for (new i; i != sizeof (Sth); ++i)
// is exactly the same as:
for (new i; i != MAX_STH; ++i)


Having a function (custom or native by samp/plugin), then yes - do that to avoid calling a function multiply times but in the above case is not the same. As for the text, only lazy programmers avoid to use it.

Ok convinced. So when you compile inserts constant value?

Konstantinos
16/05/2015, 04:18 PM
Ok convinced. So when you compile inserts constant value?

Exactly. Sorry I couldn't explain it better!

dundolina
17/05/2015, 09:03 AM
D:\after\gamemodes\GTABGW.pwn(8669) : error 017: undefined symbol "GetPlayerPoolSize"

new Float:RandomMoneyBoxVzimane[][3] =
{
{2227.74, 1516.43, 10.82}, {-724.44, 1402.81, 13.07}, {-1940.61, 1086.14, 53.09},
{-2344.37, -459.59, 80.01}, {-1674.65, -543.03, 14.14}, {-2415.30, -2142.08, 52.37},
{-1527.47, -2291.62, -5.63}, {-1111.05, -2470.04, 76.59}, {-288.23, -2163.67, 28.63},
{-376.27, -2583.97, 138.17}, {378.32, -1885.70, 2.05}, {1120.86, -2065.82, 74.42},
{1583.25, -2286.55, 13.53}, {2718.67, -2385.16, 13.63}, {2744.79, -1944.55, 17.32},
{2041.71, -1715.58, 13.54}, {2771.79, -1354.51, 50.00}, {1102.96, -1092.89, 28.46},
{727.73, -1276.13, 13.64}, {755.31, -591.31, 18.01}, {360.91, -110.02, 1.22},
{-557.35, -541.28, 25.52}, {-273.04, -955.98, 38.30}, {1242.36, 327.17, 19.75},
{2791.64, 2225.64, 14.66}, {-1955.01, -986.97, 35.89}, {-2108.89, -2376.97, 30.62},
{1853.35, 2045.54, 10.85}, {2478.85, -1437.22, 25.49}, {-2241.50, 2462.93, 4.98},
{703.36, 267.78, 21.44}, {-599.09, -1080.95, 23.66}, {-2677.68, 1503.98, 2.07},
{2582.18, -2115.22, 1.11}, {-1954.97, -986.27, 35.89}, {541.41, 830.33, -39.44},
{-2876.66, 292.77, 6.96}, {-2192.16, 2409.51, 4.95}, {2615.91, -1730.39, 6.24},
{-529.81, -991.29, 24.55}, {-1048.33, -1306.72, 128.50}, {1227.20, 2584.68, 10.82},
{1016.48, 1411.63, 10.82}, {-1593.62, 802.54, 6.82}, {-2238.23, -2478.96, 31.19},
{917.43, 2402.92, 10.82}, {1312.97, -1965.60, 29.46}, {-120.59, -1531.31, 3.07},
{-2508.68, -53.19, 25.65}, {-2762.04, 105.18, 6.99}, {1367.53, 194.54, 19.55},
{-2655.83, -102.70, 3.99}, {2161.85, -102.76, 2.75}, {2535.77, 1342.55, 10.82},
{-2059.10, 890.89, 61.85}, {1188.14, 231.38, 19.56}, {1088.81, 1073.79, 10.83},
{422.96, 2539.45, 16.52}, {-227.49, 2709.91, 62.98}, {-347.38, 1581.21, 76.30},
{-208.08, 1127.93, 19.74}, {33.24, 1155.21, 19.69}, {1582.07, -2691.56, 6.12},
{1715.25, -1912.01, 13.56}, {286.36, -1145.15, 80.91}
};

// Checking if player is in range of one of the points.
for(new i = 0; i < sizeof(RandomMoneyBoxVzimane); ++i)
{
if(!IsPlayerInRangeOfPoint(playerid, 3.0, RandomMoneyBoxVzimane[i][0], RandomMoneyBoxVzimane[i][1], RandomMoneyBoxVzimane[i][2])) continue;
// Player is in range of a point
PlayerInfo[playerid][pKufar] = 1;
Kufar = 1;
Moneybox = 0;
new fstr[48], rand = random(sizeof(RandomMoneyBoxVzimane));
format(fstr, sizeof(fstr), "Moneybox: %s взе куфара!", PlayerName(playerid));
SendClientMessageToAll(COLOR_GREEN, fstr);
SendClientMessage(playerid, COLOR_GREEN, "Ти взе куфара сега трябва да го доставиш!");
for(new x = 0, y = GetPlayerPoolSize(); x < y; ++x)
{
if(!IsPlayerConnected(x)) continue; // Foreach is a better alternative
DisablePlayerCheckpoint(x);
SetPlayerCheckpoint(x, RandomMoneyBoxVzimane[rand][0], RandomMoneyBoxVzimane[rand][1], RandomMoneyBoxVzimane[rand][2], 3.0);
}
break;
}

There are definitely much easier methods to doing this... but I'm not getting paid for this, so... you're welcome.

Konstantinos
17/05/2015, 09:10 AM
Update your includes to 0.3.7 and if you already have but it gives the error: http://forum.sa-mp.com/showthread.php?p=3460557#post3460557

dundolina
17/05/2015, 09:33 AM
I update them but have another error in console when i start server - Script [gamemodes/GTABGW.amx]: Run time error 19: "File or funcion is not found"

The file is there and it's compiled.

Konstantinos
17/05/2015, 09:39 AM
Load nativechecker plugin (it should be loaded last of all) and run the server. Post your server log.

dundolina
17/05/2015, 09:48 AM
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3z, (C)2005-2014 SA-MP Team

[12:54:34] weburl = "www.sa-mp.com" (string)
[12:54:34]
[12:54:34] Server Plugins
[12:54:34] --------------
[12:54:34] Loading plugin: mysql
[12:54:34]

> MySQL plugin R4-2 successfully loaded.

[12:54:34] Loaded.
[12:54:34] Loading plugin: streamer
[12:54:34]

*** Streamer Plugin v2.7.5.2 by Incognito loaded ***

[12:54:34] Loaded.
[12:54:34] Loading plugin: sscanf
[12:54:34]

[12:54:34] ===============================

[12:54:34] sscanf plugin loaded.

[12:54:34] Version: 2.8.1

[12:54:34] (c) 2012 Alex "******" Cole

[12:54:34] ===============================

[12:54:34] Loaded.
[12:54:34] Loading plugin: nativechecker
[12:54:34] Loaded.
[12:54:34] Loaded 4 plugins.

[12:54:34]
[12:54:34] Ban list
[12:54:34] --------
[12:54:34] Loaded: samp.ban
[12:54:34]
[12:54:34]
[12:54:34] Filterscripts
[12:54:34] ---------------
[12:54:34] Loading filterscript 'BIZZ.amx'...
[12:54:34] -------------------------------------
[12:54:34] PPC Business filterscript initialized
[12:54:34] Businesses loaded: 81
[12:54:34] -------------------------------------
[12:54:34] Loading filterscript 'House.amx'...
[12:54:34] ----------------------------------------
[12:54:34] PPC HOUSE
[12:54:34] Houses loaded: 345
[12:54:34] ----------------------------------------
[12:54:34] Loading filterscript 'MinigamesSystem.amx'...
[12:54:34] Loaded 3 filterscripts.

[12:54:34] Error: Function not registered: 'GetPlayerPoolSize'
[12:54:34] Script[gamemodes/GTABGW.amx]: Run time error 19: "File or function is not found"
[12:54:34] Number of vehicle models: 0

Threshold
17/05/2015, 09:49 AM
SA-MP Dedicated Server
----------------------
v0.3z, (C)2005-2014 SA-MP Team

Still 0.3z... I dunno how people can keep getting this wrong :/