I want to use my GasStation array -
JaKe Elite - 09.10.2012
Hey,
How can i able create a pickup and map icon using the GasStation Array without putting the coordinates one by one.
here is my gas station array
pawn Код:
new Float:GasStation[28][3] =
{
{2146.7766,2747.4424,10.8203},
{2638.5972,1106.7181,10.8203},
{1597.3271,2197.7712,10.8203},
{608.5480,1699.3431,6.9922},//One
{618.5945,1684.5210,6.9922},//One
{-1470.1311,1863.6323,32.6328},
{-737.2454,2742.9482,47.2266},
{656.9113,-564.4317,16.5101,
{2202.2349,2474.3494,10.5258},
{614.9333,1689.7418,6.6968},
{-1328.8250,2677.2173,49.7665},
{70.3882,1218.6783,18.5165},
{2113.7390,920.1079,10.5255},
{-1327.7218,2678.8723,50.0625},
{-2409.5752,976.3114,45.2969},
{-2026.0743,156.6390,28.7872},
{-2244.5063,-2561.0781,31.9219,
{-1603.3645,-2709.4622,48.3874},//Two
{-1609.7147,-2717.6572,48.3874},//Two
{-88.9507,-1164.7794,2.3085},//Three
{-93.0625,-1173.2089,2.3244},//Three
{1003.7032,-937.5828,42.3281},
{1940.6816,-1770.7999,13.3906},//Four
{1940.0111,-1776.4730,13.3906},//Four
{1381.7468,459.1537,20.3452},
{-1680.0511,408.4660,7.1797},//Five
{-1672.9927,415.2118,7.1797},//Five
{-730.05,2744.22,47.22}
};
Re: I want to use my GasStation array -
Roel - 09.10.2012
pawn Код:
for(new i = 0; i < sizeof(GasStation); i++)
{
GasStation[i][0],GasStation[i][2],GasStation[i][3] // X,Y,Z
}
I hope you understand that those 0 - 1- 2 are X , Y ,Z so you just put a CreatePlayerMapIcon or something, and a CreatePickup thing in this, and edit the corods to this three.
Re: I want to use my GasStation array -
JaKe Elite - 09.10.2012
Thanks bro.
Rep++
Re: I want to use my GasStation array -
mamorunl - 09.10.2012
An array index is as accessed as follows:
Given an array with 3 cells (Array[3]) you access the elements as follows: Array[0], Array[1], Array[2]. So: The index-1 is the index in the array as the keys of an array start at 0.
Re: I want to use my GasStation array -
JaKe Elite - 09.10.2012
Array index out of bounds is fixed.
Re: I want to use my GasStation array -
XtremeR - 09.10.2012
works fine tried compiling it,
pawn Код:
for(new i = 0; i < sizeof(GasStation); i++) {
CreatePickup(1241, 1, GasStation[i][0], GasStation[i][1], GasStation[i][2], -1);
}
hope that helps
Re: I want to use my GasStation array -
JaKe Elite - 09.10.2012
Still the same.
Код:
C:\DOCUME~1\Romel\MYDOCU~1\AWESOM~1\GAMEMO~1\Truck.pwn(105) : error 008: must be a constant expression; assumed zero
C:\DOCUME~1\Romel\MYDOCU~1\AWESOM~1\GAMEMO~1\Truck.pwn(113 -- 125) : error 008: must be a constant expression; assumed zero
Re: I want to use my GasStation array -
XtremeR - 09.10.2012
will work dam sure
pawn Код:
new Float:GasStation[28][3] =
{
{2146.7766,2747.4424,10.8203},
{2638.5972,1106.7181,10.8203},
{1597.3271,2197.7712,10.8203},
{608.5480,1699.3431,6.9922},//One
{618.5945,1684.5210,6.9922},//One
{-1470.1311,1863.6323,32.6328},
{-737.2454,2742.9482,47.2266},
{656.9113,-564.4317,16.5101},
{2202.2349,2474.3494,10.5258},
{614.9333,1689.7418,6.6968},
{-1328.8250,2677.2173,49.7665},
{70.3882,1218.6783,18.5165},
{2113.7390,920.1079,10.5255},
{-1327.7218,2678.8723,50.0625},
{-2409.5752,976.3114,45.2969},
{-2026.0743,156.6390,28.7872},
{-2244.5063,-2561.0781,31.9219},
{-1603.3645,-2709.4622,48.3874},//Two
{-1609.7147,-2717.6572,48.3874},//Two
{-88.9507,-1164.7794,2.3085},//Three
{-93.0625,-1173.2089,2.3244},//Three
{1003.7032,-937.5828,42.3281},
{1940.6816,-1770.7999,13.3906},//Four
{1940.0111,-1776.4730,13.3906},//Four
{1381.7468,459.1537,20.3452},
{-1680.0511,408.4660,7.1797},//Five
{-1672.9927,415.2118,7.1797},//Five
{-730.05,2744.22,47.22}
};
Re: I want to use my GasStation array -
JaKe Elite - 09.10.2012
Now i've bigger problem.
The map icon doesn't work.
And even the refuel system doesn't work
every time i press Y it says i'm not in any gas stations
even i'm in the refuel pickup.
I test this.
pawn Код:
//OnPlayerSpawn
new Float:gx, Float:gy, Float:gz;
for(new i = 0; i < sizeof(GasStation); i++)
{
gx = GasStation[i][0];
gy = GasStation[i][1];
gz = GasStation[i][2];
}
SetPlayerMapIcon(playerid, 0, gx, gy, gz, 56, COLOR_WHITE, MAPICON_LOCAL);
//OnPlayerKeyStateChange
new Float:x, Float:y, Float:z;
if(newkeys & KEY_YES)
{
for(new i = 0; i < sizeof(GasStation); i++)
{
x = GasStation[i][0];
y = GasStation[i][1];
z = GasStation[i][2];
}
if(IsPlayerInRangeOfPoint(playerid, 2.5, x, y, z) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(isrefuelling[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already refuelling!");
if (GetPlayerMoney(playerid) - 80 < 0) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money to refuel!");
GivePlayerMoney(playerid, -80);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 0);
isrefuelling[playerid] = 1;
TextDrawSetString(td_fuel[playerid], "Refuelling...");
GameTextForPlayer(playerid, "~r~Refuelling...~n~~w~Please wait!", 5000, 3);
SetTimerEx("VehicleRefuel", 5000, false, "i", playerid);
}
else if(!IsPlayerInRangeOfPoint(playerid, 2.5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "You are not in any Gas Stations!");
}
Re: I want to use my GasStation array -
Roel - 09.10.2012
pawn Код:
new Float:gx, Float:gy, Float:gz;
for(new i = 0; i < sizeof(GasStation); i++)
{
gx = GasStation[i][0];
gy = GasStation[i][1];
gz = GasStation[i][2];
}
SetPlayerMapIcon(playerid, 0, gx, gy, gz, 56, COLOR_WHITE, MAPICON_LOCAL);
Thatwill only set the last map icon. Use it like htis
pawn Код:
new Float:gx, Float:gy, Float:gz;
for(new i = 0; i < sizeof(GasStation); i++)
{
gx = GasStation[i][0];
gy = GasStation[i][1];
gz = GasStation[i][2];
SetPlayerMapIcon(playerid, 0, gx, gy, gz, 56, COLOR_WHITE, MAPICON_LOCAL);
}
pawn Код:
for(new i = 0; i < sizeof(GasStation); i++)
{
x = GasStation[i][0];
y = GasStation[i][1];
z = GasStation[i][2];
if(IsPlayerInRangeOfPoint(playerid, 2.5, x, y, z) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(isrefuelling[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already refuelling!");
if (GetPlayerMoney(playerid) - 80 < 0) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money to refuel!");
GivePlayerMoney(playerid, -80);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 0);
isrefuelling[playerid] = 1;
TextDrawSetString(td_fuel[playerid], "Refuelling...");
GameTextForPlayer(playerid, "~r~Refuelling...~n~~w~Please wait!", 5000, 3);
SetTimerEx("VehicleRefuel", 5000, false, "i", playerid);
}
else if(!IsPlayerInRangeOfPoint(playerid, 2.5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "You are not in any Gas Stations!");
}
Same for your pickups, you have to create the pickups inside the loop else it just won't work.