Quantcast
Viewing all articles
Browse latest Browse all 18226

Array error?

Since I can't figure out how 3D arrays work, I split them up into four different variable names. (( http://forum.sa-mp.com/showthread.php?t=646457 ))

Anyways, whenever I use the command /work, it always shows up "Gas Station 1" and "Gas Station 2". But the XYZ coordinates of four different TrailerDestination variables work, except for the Name variable.
PHP Code:

enum Trailer
{
    
Name[32],
    
Float:DestX,
    
Float:DestY,
    
Float:DestZ
};

#define MAX_TRAILER1DESTINATION 2
new Trailer1Destination[MAX_TRAILER1DESTINATION][Trailer] =
{
    {
"Gas Station 1"1941.9574, -1790.263713.3828},
    {
"Gas Station 2"980.5435, -921.293041.2895}
};


#define MAX_TRAILER2DESTINATION 1
new Trailer2Destination[MAX_TRAILER2DESTINATION][Trailer] =
{
    {
"Ammu Nation"1363.7482, -1287.414813.5469}
};


#define MAX_TRAILER3DESTINATION 6
new Trailer3Destination[MAX_TRAILER3DESTINATION][Trailer] =
{
    {
"Well Stacked Pizza"2094.8977, -1800.015413.3426},
    {
"Cluckin' Bell"2370.5210, -1910.614713.1099},
    {
"Cluckin' Bell"2408.2141, -1482.215723.5552},
    {
"Cluckin' Bell"922.3662, -1358.412513.0151},
    {
"Joe's Sticky Ring"1015.9811, -1345.229213.1014},
    {
"Burger Shot"788.3559, -1635.677513.1099}
};


#define MAX_TRAILER4DESTINATION 2
new Trailer4Destination[MAX_TRAILER4DESTINATION][Trailer] =
{
    {
"Construction Materials"1857.0723, -1321.282313.1993},
    {
"Ammu Nation"1363.82, -1287.414813.5469}
};

CMD:work(playeridparams[])
{
    new 
Float:xFloat:yFloat:zstring[512] = "Destination\tDistance\n";
    if(
IsPlayerInWork(playerid)) return SendClientMessage(playeridCOLOR_PLAYER"ERROR: You are still on work! Use /cancelwork to cancel your current work.");
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_PLAYER"ERROR: You are not in any vehicle!");
    if(!
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playeridCOLOR_PLAYER"ERROR: You do not have any trailers attached!");
     
GetPlayerPos(playeridxyz);
     switch(
GetVehicleTrailerType(GetPlayerVehicleID(playerid)) == 0)
    {
        case 
0: for(new 0MAX_TRAILER1DESTINATIONi++) format(stringsizeof(string), "%s%s\t%0.2fm\n"stringTrailer1Destination[i][Name], GetDistance(xyzTrailer1Destination[i][DestX], Trailer1Destination[i][DestY], Trailer1Destination[i][DestZ]));
        case 
1: for(new 0MAX_TRAILER2DESTINATIONi++) format(stringsizeof(string), "%s%s\t%0.2fm\n"stringTrailer2Destination[i][Name], GetDistance(xyzTrailer2Destination[i][DestX], Trailer2Destination[i][DestY], Trailer2Destination[i][DestZ]));
        case 
2: for(new 0MAX_TRAILER3DESTINATIONi++) format(stringsizeof(string), "%s%s\t%0.2fm\n"stringTrailer3Destination[i][Name], GetDistance(xyzTrailer3Destination[i][DestX], Trailer3Destination[i][DestY], Trailer3Destination[i][DestZ]));
        case 
3: for(new 0MAX_TRAILER4DESTINATIONi++) format(stringsizeof(string), "%s%s\t%0.2fm\n"stringTrailer4Destination[i][Name], GetDistance(xyzTrailer4Destination[i][DestX], Trailer4Destination[i][DestY], Trailer4Destination[i][DestZ]));
    }
    
ShowPlayerDialog(playeridDIALOG_WORKDIALOG_STYLE_TABLIST_HEADERS"Select Destination"string"Select""Cancel");
    return 
1;



Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>