SA-MP Forums Archive
Positions 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: Positions Problem (/showthread.php?tid=553566)



Positions Problem - Ox1gEN - 30.12.2014

I am trying to check if the player is in range of one of the dealerships and it just doesn't work.
I've encountered a problem like this one before I just don't know the solution now.

pawn Код:
YCMD:v_buy(playerid, params[], help) { //Accessing the vehicle purhcasing menu.
   
    if(PR[playerid][VehiclesOwned] >= 1) return SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You already reach the maximum amount of vehicles you can have!");
    else {
        for(new i = 0 ; i < MAX_DEALERSHIPS ; i ++) { //This command doesn't work properly, fix it.
            if(IsPlayerInRangeOfPoint(playerid, 5, DS[i][DsLocX], DS[i][DsLocY], DS[i][DsLocZ])) {
                format(ZString, sizeof(ZString), "Saloon Vehicles\nStation Wagons\nIndustrial\nPublic Service\nBikes\nHelicopters\nAir Planes\nSport Vehicles");
                return 1;
            } else {
                SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You are not near any dealership!");
                break;
            }
        }
        ShowPlayerDialog(playerid, DIALOG_DEALERSHIP_BUY, DIALOG_STYLE_LIST, "Vehicles DealerShip", ZString, "Purchase", "Close");
    }
    return 1;
}



Re: Positions Problem - Ox1gEN - 30.12.2014

Quote:
Originally Posted by ******
Посмотреть сообщение
When you say "doesn't work", what exactly does it do, and what should it do? Also, you haven't declared "ZString"
It is declared and it does work.

It just won't do what I want it to do.
I want it to check if the player is in range of one of the dealerships and if he is show him the dialog, otherwise don't.


Re: Positions Problem - Alvord - 30.12.2014

Hi, try this one:

pawn Код:
YCMD:v_buy(playerid, params[], help)
{
     if(PR[playerid][VehiclesOwned] >= 1)
          return SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You already reach the maximum amount of vehicles you can have!");
     
     new dealershipid = -1;
     for(new i = 0; i < MAX_DEALERSHIPS; i++)
     {
          if(IsPlayerInRangeOfPoint(playerid, 5.0, DS[i][DsLocX], DS[i][DsLocY], DS[i][DsLocZ]))
          {
               dealershipid = i;
          }
     }
     
     if(dealershipid != -1)
     {
          format(ZString, sizeof(ZString), "Saloon Vehicles\nStation Wagons\nIndustrial\nPublic Service\nBikes\nHelicopters\nAir Planes\nSport Vehicles");
          ShowPlayerDialog(playerid, DIALOG_DEALERSHIP_BUY, DIALOG_STYLE_LIST, "Vehicles DealerShip", ZString, "Purchase", "Close");
     }
     else
     {
          SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You are not near any dealership!");
     }
     return 1;
}



Re: Positions Problem - BroZeus - 30.12.2014

The problem is if u are in range of point then it formats the strings and returns 1 so if u return 1 then the command stops from that point.. You have formated the string but forgoten to show it in form of dialog in the loop
And there are some other bugs which i have fixed below
so it would be like this
pawn Код:
YCMD:v_buy(playerid, params[], help)
 {    
        if(PR[playerid][VehiclesOwned] >= 1) return SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You already reach the maximum amount of vehicles you can have!");    
        for(new i = 0 ; i < MAX_DEALERSHIPS ; i ++)
          {
            if(IsPlayerInRangeOfPoint(playerid, 5, DS[i][DsLocX], DS[i][DsLocY], DS[i][DsLocZ]))
              {
                format(ZString, sizeof(ZString), "Saloon Vehicles\nStation Wagons\nIndustrial\nPublic Service\nBikes\nHelicopters\nAir Planes\nSport Vehicles");
                  ShowPlayerDialog(playerid, DIALOG_DEALERSHIP_BUY, DIALOG_STYLE_LIST, "Vehicles DealerShip", ZString, "Purchase", "Close");//add this line here
                return 1;
              }
           }
           SendClientMessage(playerid, COLOR_ERROR, "[ ! ] You are not near any dealership!");      
    return 1;
}



Re: Positions Problem - Ox1gEN - 30.12.2014

Thanks.