MySQL question
#1

Uh, I want to make a storage system inside my druglab but my question is.. how do I get the information from the druglab that the player is in? This is my code

PHP код:
else if(!strcmp(params"info"))
    {
        for(new 
0MAX_DLABSi++)
        {
            if(
IsPlayerInRangeOfPoint(playerid60.0DrugLabs[i][ExitX], DrugLabs[i][ExitY], DrugLabs[i][ExitZ]))
            {
                
format(stringsizeof(string), ""COL_ORANGE"DROGURI:\n__________\n"string);
                
format(stringsizeof(string), "%sHeroina: %d\n"stringDrugLabs[i][Heroina]);
                
format(stringsizeof(string), "%sHeroina: %d\n"stringDrugLabs[i][Heroina]);
            }
        }
    } 
The coords will be right because, if we think logic, it will go through all the druglabs and put the coords there, and if the player is in range of one of them it will work, but how does the system know that the player is inside druglab 3 so it will return the stock of the druglab with id 3?

Didn't tested yet but probably in the code above it will return the information from all druglabs.
Reply
#2

It will return only the lab you're in (unless a two labs are too close together). Your code loops through all labs, and checks if you are near it with IsPlayerInRangeOfPoint. Only change I'd suggest is adding break when a lab is found, so no more useless iterations are done
pawn Код:
for(new i = 0; i < MAX_DLABS; i++)
{
    if(IsPlayerInRangeOfPoint(playerid, 60.0, DrugLabs[i][ExitX], DrugLabs[i][ExitY], DrugLabs[i][ExitZ]))
    {
        format(string, sizeof(string), ""COL_ORANGE"DROGURI:\n__________\n", string);
        format(string, sizeof(string), "%sHeroina: %d\n", string, DrugLabs[i][Heroina]);
        format(string, sizeof(string), "%sHeroina: %d\n", string, DrugLabs[i][Heroina]);
        break;
    }
}
Reply
#3

Make a variable say pDrugLab[MAX_PLAYERS] and store id of Drug Lab when player enters drug lab. Now in command check if player is in druglab interior if yes then use id stored in pDrugLab[playerid].

In the code you are missing the break; inside 'if' statement body.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)