Trunk system telling me i am not near the car.
#1

Well, hello again. Made a trunk system, that should open the trunk when we are near an owned car with /trunkinfo but it just tells me i am not near any buyable vehicle.. :S

I am really near them.. Used more distance range thanf or /lock and /lock works...
I verified all, it's a simmple code, i don't really know why it fails...

pawn Код:
CMD:trunkinfo(playerid, params[])
{
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, CarInfo[i][X], CarInfo[i][Y], CarInfo[i][Z]))
        {
            if(CarInfo[i][Lock] == 0)
            {
                GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,true,objective);
                new string[128];
                format(string, sizeof(string), "||--------------Trunk---------------||");
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Weapon Slot 1: %d with %d ammo.", CarInfo[i][Weapon1], CarInfo[i][Weapon1Ammo]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Weapon Slot 2: %d with %d ammo.", CarInfo[i][Weapon2], CarInfo[i][Weapon2Ammo]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Weapon Slot 3: %d with %d ammo.", CarInfo[i][Weapon3], CarInfo[i][Weapon3Ammo]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Weapon Slot 4: %d with %d ammo.", CarInfo[i][Weapon4], CarInfo[i][Weapon4Ammo]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Weapon Slot 5: %d with %d ammo.", CarInfo[i][Weapon5], CarInfo[i][Weapon5Ammo]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "Materials: %d ", CarInfo[i][Materials]);
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                format(string, sizeof(string), "||----------------------------------||");
                SendClientMessage(playerid, COLOR_LIGHTRED, string);
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "This vehicle is locked.");
        }
        else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near any vehicle.");
    }
    return 1;
}
Didn't even made the good look saying gun names and stuff, cos i wanted to make the basic first, but it says me the samething all the time..

Tried with returns, without returns..
Reply
#2

Same again, your using return in a loop.

pawn Код:
else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near any vehicle.");
AKA, if id 1 is not near you, it will return that.
Reply
#3

Damn, so how do i return that when there are no vehicles near and why it shows if ID 1 not near? xD I am really mindfucked with that returns shit..
Reply
#4

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Damn, so how do i return that when there are no vehicles near and why it shows if ID 1 not near? xD I am really mindfucked with that returns shit..
Count the amount of vehicles you are near, Posted an example in your previous help request
Reply
#5

Thanks. Will try out.
Reply
#6

Something like this?

pawn Код:
CMD:trunkinfo(playerid, params[])
{
    new iTargetID;
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, CarInfo[i][X], CarInfo[i][Y], CarInfo[i][Z]))
        {
            iTargetID = i;
        }
    }
    GetVehicleParamsEx(iTargetID,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(iTargetID,engine,lights,alarm,doors,bonnet,true,objective);
    new string[128];
    format(string, sizeof(string), "||--------------Trunk---------------||");
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Weapon Slot 1: %d with %d ammo.", CarInfo[iTargetID][Weapon1], CarInfo[iTargetID][Weapon1Ammo]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Weapon Slot 2: %d with %d ammo.", CarInfo[iTargetID][Weapon2], CarInfo[iTargetID][Weapon2Ammo]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Weapon Slot 3: %d with %d ammo.", CarInfo[iTargetID][Weapon3], CarInfo[iTargetID][Weapon3Ammo]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Weapon Slot 4: %d with %d ammo.", CarInfo[iTargetID][Weapon4], CarInfo[iTargetID][Weapon4Ammo]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Weapon Slot 5: %d with %d ammo.", CarInfo[iTargetID][Weapon5], CarInfo[iTargetID][Weapon5Ammo]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "Materials: %d ", CarInfo[iTargetID][Materials]);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "||----------------------------------||");
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    return 1;
}
Reply
#7

No


Don't place iTrargetId in a loop,

make a variable count = 0;

and for each car you are close to, the count goes ++;


Then just check if count > 0
Reply
#8

This? I hope so. xD

pawn Код:
CMD:trunkinfo(playerid, params[])
{
    new count;
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, CarInfo[i][X], CarInfo[i][Y], CarInfo[i][Z]))
        {
            count++;
        }
    }
    if(count > 0)
    {
        GetVehicleParamsEx(count,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(count,engine,lights,alarm,doors,bonnet,true,objective);
        new string[128];
        format(string, sizeof(string), "||--------------Trunk---------------||");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Weapon Slot 1: %d with %d ammo.", CarInfo[count][Weapon1], CarInfo[count][Weapon1Ammo]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Weapon Slot 2: %d with %d ammo.", CarInfo[count][Weapon2], CarInfo[count][Weapon2Ammo]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Weapon Slot 3: %d with %d ammo.", CarInfo[count][Weapon3], CarInfo[count][Weapon3Ammo]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Weapon Slot 4: %d with %d ammo.", CarInfo[count][Weapon4], CarInfo[count][Weapon4Ammo]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Weapon Slot 5: %d with %d ammo.", CarInfo[count][Weapon5], CarInfo[count][Weapon5Ammo]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "Materials: %d ", CarInfo[count][Materials]);
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
        format(string, sizeof(string), "||----------------------------------||");
        SendClientMessage(playerid, COLOR_LIGHTRED, string);
    }
    return 1;
}
Reply
#9

nope, your getting close though


your setting count to 1 and using count as car id aswell,

Use ANOTHER loop after the count loop, like outside it but to loop trough the vehicles again and then use your normal code.


And for if(count == 0)
return SCM(playerid, COLOR_GREY," You are not near a turtle!");
Reply
#10

Quote:
Originally Posted by milanosie
Посмотреть сообщение
nope, your getting close though


your setting count to 1 and using count as car id aswell,

Use ANOTHER loop after the count loop, like outside it but to loop trough the vehicles again and then use your normal code.


And for if(count == 0)
return SCM(playerid, COLOR_GREY," You are not near a turtle!");
Hmm, about the if(count == 0) message i understood, but the other loop didn't..
You mean opening a "for" if again, and check for vehicles again? Didn't understand it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)