Loop through defined objects?
#8

Quote:
Originally Posted by RALL0
Посмотреть сообщение
The comment at the code explains what isn't working well
pawn Код:
CMD:unloadforklift(playerid, params[])
{
    new Float:Pos[5];
    new vehicleid = GetPlayerVehicleID(playerid);
    if(!IsAForklift(vehicleid)) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You must be a driver of a forklift to load a forklift.");
    if(ForkliftLoaded[vehicleid] == 0) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}This forklift isnґt carrying a crate.");
    ForkliftLoaded[vehicleid] = 0;
    DestroyObject(ForkliftObject[vehicleid][vObject]);
    GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
    GetXYInFrontOfPlayer(playerid, Pos[0], Pos[1], 5);
    for(new i = 0; i < 5; i++)
    {
        CrateObjectsPlaced[i] = CreateObject(964, Pos[0]+90, Pos[1], Pos[2]-0,72, Pos[3]-45, -45,180);
    }
    return 1;
}
   
   
CMD:loadforklift(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new crate = PlayerNearCrate(playerid);
    new crate1 = PlayerNearPlacedCrate(playerid);
    if(ForkliftLoaded[vehicleid] == 1) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}This forklift is already carrying a crate.");
    if(!IsAForklift(vehicleid)) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You must be a driver of a forklift to load a forklift.");
    if(crate != -1)
    {
        ForkliftLoaded[vehicleid] = 1;
        DestroyObject(CrateObjects[crate]);
        ForkliftObject[vehicleid][vObject] = CreateObject(964, 0, 0.9, -0.12, 0, 0, 0);
        AttachObjectToVehicle(ForkliftObject[vehicleid][vObject], vehicleid, 0, 0.9, -0.12, 0, 0, 0);
    }
    else if(crate1 != -1)
    {
        ForkliftLoaded[vehicleid] = 1;
        DestroyObject(CrateObjectsPlaced[crate1]);//It doesn't really destroy the nearest crate, however I suspect that the trouble is at the loop of mine, because the DestroyObject thats a couple of line above this is working fine.
        ForkliftObject[vehicleid][vObject] = CreateObject(964, 0, 0.9, -0.12, 0, 0, 0);
        AttachObjectToVehicle(ForkliftObject[vehicleid][vObject], vehicleid, 0, 0.9, -0.12, 0, 0, 0);
    }
    else return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You aren't near any crate.");
    return 1;
}
The problem is that if crate will be 0 or any other positive number the "else if" wont be called, change the "else if" to just "if".
Reply


Messages In This Thread
Loop through defined objects? - by RALL0 - 17.08.2013, 22:07
Re: Loop through defined objects? - by Edix - 17.08.2013, 22:13
Re: Loop through defined objects? - by RALL0 - 17.08.2013, 23:10
Re: Loop through defined objects? - by Youarex - 18.08.2013, 00:09
Re: Loop through defined objects? - by SuperViper - 18.08.2013, 06:29
Re: Loop through defined objects? - by Edix - 18.08.2013, 07:52
Re: Loop through defined objects? - by RALL0 - 18.08.2013, 13:41
Re: Loop through defined objects? - by Edix - 18.08.2013, 13:50
Re: Loop through defined objects? - by RALL0 - 18.08.2013, 14:57
Re: Loop through defined objects? - by RALL0 - 18.08.2013, 20:28

Forum Jump:


Users browsing this thread: 2 Guest(s)