SA-MP Forums Archive
Help NPC - 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: Help NPC (/showthread.php?tid=590237)



Help NPC - MushLand - 27.09.2015

Help Please

Error:
Код:
C:\Users\Mush\Desktop\gm\filterscripts\bus.pwn(449) : error 029: invalid expression, assumed zero
Code in gm:
Код:
new Float:busx, Float:busy, Float:busz, Float:angle;
                if(BusID[playerid] == 1)
                {
                    GetVehiclePos(NPCBlueBus, busx, busy, busz);
                    GetVehicleZAngle(NPCBlueBus, angle);
                }
                else
                {
                    GetVehiclePos(NPCBlackBus, busx, busy, busz);
                    GetVehicleZAngle(NPCBlackBus, angle);
                }
                else
                {
                    GetVehiclePos(NPCRedBus, busx, busy, busz);
                    GetVehicleZAngle(NPCRedBus, angle);
                }



Re: Help NPC - iggy1 - 27.09.2015

Код:
if(BusID[playerid] == 1)
{
    GetVehiclePos(NPCBlueBus, busx, busy, busz);
    GetVehicleZAngle(NPCBlueBus, angle);
}
else
{
    GetVehiclePos(NPCBlackBus, busx, busy, busz);
    GetVehicleZAngle(NPCBlackBus, angle);
}
Use 'else if' if you need to add more checks.

Review https://sampwiki.blast.hk/wiki/Control_Structures

EDIT: Just realized that code does the same thing in both blocks, because you dont change the variables 'NPCBlueBus', 'busx', 'busy' and 'busz'. So it will not do what you want it to.


Re: Help NPC - MushLand - 27.09.2015

blue and black bus with the bus go , but when you put it on the red bus gives me error,and the error pawno else if I give my close


Re: Help NPC - iggy1 - 27.09.2015

Oh yes i missed that.

Set it up like this:

Код:
if(BusID[playerid] == 1)
{
    GetVehiclePos(NPCBlueBus, busx, busy, busz);
    GetVehicleZAngle(NPCBlueBus, angle);
}
else if(BusID[playerid] == 2)//change '2' to the blackbus id
{
    GetVehiclePos(NPCBlackBus, busx, busy, busz);
    GetVehicleZAngle(NPCBlackBus, angle);
}
else if(BusID[playerid] == 3)//change '3' to the blackbus id
{
    GetVehiclePos(NPCRedBus, busx, busy, busz);
    GetVehicleZAngle(NPCRedBus, angle);
}
else
{
    //it's not a black, blue or red bus
}
Will be easier to read/edit if you define the constants.

Код:
#define NPC_BLUE_BUS 1

//then you can do
if(BusID[playerid] == NPC_BLUE_BUS)



Re: Help NPC - MushLand - 27.09.2015

thanks man, I have a misunderstanding if you can help me how can I change a file from rec npcmodes