you are not near a vehicle,
#1

Hey, my /tputgun (trunk putgun) says that im not near a vehicle,

what am I doing wrong

pawn Код:
CMD:tputgun(playerid, params[])
{
    for(new v = 1; v < sizeof(CarInfo); v++)
    {
        new Float:vpx, Float:vpy, Float:vpz;
        GetVehiclePos(v, vpx, vpy, vpz);
        if(IsPlayerInRangeOfPoint(playerid, 4, vpx, vpy, vpz))
        {
        if(vehilocked[v] == 1) return SendClientMessage(playerid, COLOR_RED, "This vehicle is locked!");
        new str[128];
        new name[24];
        GetPlayerName(playerid, name, 24);
        new ammo = GetPlayerAmmo(playerid);
        new weapon = GetPlayerWeapon(playerid);
        new modelid = GetVehicleModel(v);
        new m = GetVehicleModel(v);
        if(modelid == 460 || modelid == 464 || modelid == 476 || modelid == 511 || modelid == 512 || modelid == 513 || modelid == 519 || modelid == 520 || modelid == 553 || modelid == 577 || modelid == 592 || modelid == 593) return SendClientMessage(playerid, COLOR_GREY, "This vehicle does not have a trunk!");
        if(modelid == 448 || modelid == 461 || modelid == 462 || modelid == 463 || modelid == 468 || modelid == 471 || modelid == 481 || modelid == 509 || modelid == 510 || modelid == 521 || modelid == 522 || modelid == 523 || modelid == 581 || modelid == 586) return SendClientMessage(playerid, COLOR_GREY, "This vehicle does not have a trunk!");
        if(modelid == 509 || modelid == 481 || modelid == 510) return SendClientMessage(playerid, COLOR_GREY, "This vehicle does not have a trunk!");
        if(modelid == 430 || modelid == 446 || modelid == 452 || modelid == 453 || modelid == 454 || modelid == 472 || modelid == 473 || modelid == 484 || modelid == 493) return SendClientMessage(playerid, COLOR_GREY, "This vehicle does not have a trunk!");
        if(m == 424 || m == 432 || m == 449 || m == 457 || m == 485 || m == 486 || m == 500 || m == 532 || m == 537 || m == 568 || m == 571 || m == 572 || m == 573 || m == 574 || m == 429 || m == 480 || m == 533 || m == 536 || m == 467 || m == 575) return SendClientMessage(playerid, COLOR_GREY, "This vehicle does not have a trunk!");
        if(trunk[v][vwep1] == weapon || trunk[v][vwep1a] == 0)
        {
            new bullets;
            new wepn[24];
            GetWeaponName(weapon, wepn, 24);
            if(sscanf(params, "i", bullets)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /tputgun [Ammo]");
            if(bullets > ammo) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much ammo!");
            if(bullets + trunk[v][vwep1a] > 7500) return SendClientMessage(playerid, COLOR_GREY, "Trunk can not have more then 7500 ammo on one slot!");
            if(bullets < 1 ) return SendClientMessage(playerid, COLOR_GREY, "Negative Ammo is not possible! Use /ttakegun instead");
            trunk[v][vwep1] = weapon;
            trunk[v][vwep1a] = trunk[v][vwep1a] + bullets;
            GivePlayerWeapon(playerid, weapon, -bullets);
            format(str, sizeof(str), "%s places their %s into the trunk", name, wepn);
            ProxDetector(15.0, playerid, str, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
        }
        else if(trunk[v][vwep2] == weapon || trunk[v][vwep2a] == 0)
        {
            new bullets;
            new wepn[24];
            GetWeaponName(weapon, wepn, 24);
            if(sscanf(params, "i", bullets)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /tputgun [Ammo]");
            if(bullets > ammo) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much ammo!");
            if(bullets + trunk[v][vwep2a] > 7500) return SendClientMessage(playerid, COLOR_GREY, "Trunk can not have more then 7500 ammo on one slot!");
            if(bullets < 1 ) return SendClientMessage(playerid, COLOR_GREY, "Negative Ammo is not possible! Use /ttakegun instead");
            trunk[v][vwep2] = weapon;
            trunk[v][vwep2a] = trunk[v][vwep2a] + bullets;
            GivePlayerWeapon(playerid, weapon, -bullets);
            format(str, sizeof(str), "%s places their %s into the trunk", name, wepn);
            ProxDetector(15.0, playerid, str, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
        }
        else if(trunk[v][vwep3] == weapon || trunk[v][vwep3a] == 0)
        {
            new bullets;
            new wepn[24];
            GetWeaponName(weapon, wepn, 24);
            if(sscanf(params, "i", bullets)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /tputgun [Ammo]");
            if(bullets > ammo) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much ammo!");
            if(bullets + trunk[v][vwep3a] > 7500) return SendClientMessage(playerid, COLOR_GREY, "Trunk can not have more then 7500 ammo on one slot!");
            if(bullets < 1 ) return SendClientMessage(playerid, COLOR_GREY, "Negative Ammo is not possible! Use /ttakegun instead");
            trunk[v][vwep3] = weapon;
            trunk[v][vwep3a] = trunk[v][vwep3a] + bullets;
            GivePlayerWeapon(playerid, weapon, -bullets);
            format(str, sizeof(str), "%s places their %s into the trunk", name, wepn);
            ProxDetector(15.0, playerid, str, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
        }
        else return SendClientMessage(playerid, COLOR_GREY, "Trunk is full! Take some stuff out first!");
    }
    else return SCM(playerid, COLOR_GREY, "You are not near a vehicle! ");
    }
    return 1;
}
Reply
#2

I think the for cycle can't reach the vehicle's id you are searching for, because return stops it after finding a vehicle that's not in your range. Use continue instead of return.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)