SA-MP Forums Archive
Code error - 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: Code error (/showthread.php?tid=576551)



Code error - LuisPark - 05.06.2015

I have an simple code, but may i make a misstake. when i compile it make pawn crash, when i remove it, pawn be normal. Please help and sr for my bad english
Code
PHP код:
CMD:dathanglenxe(playeridparams[]}
{
    new 
carid GetPlayerVehicleID(playerid);
     new 
closestcar GetClosestCar(playeridcarid);
      if(
IsPlayerInRangeOfVehicle(playeridclosestcar6.0) && IsAMatsCar(closestcar))
    {
    new 
engine,lights,alarm,doors,bonnet,boot,objective;
    
GetVehicleParamsEx(closestcar,engine,lights,alarm,doors,bonnet,boot,objective);
    if(
boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET)
    {
    
SendClientMessageEx(playeridCOLOR_GRAD1"The vehicle's trunk must be opened in order to search it.");
    return 
1;
    
PlayerInfo[playerid][pHeroin] = 1;
    
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
    
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
    }
    else
    {
         
SendClientMessageEx(playeridCOLOR_GRAD1"Ban khong gan mot chiec xe cho vat lieu.");
     }
     return 
1;
     }




AW: Code error - Kaliber - 05.06.2015

I think you wanna write it like this:

Код:
CMD:dathanglenxe(playerid, params[])
{
    new carid = GetPlayerVehicleID(playerid),closestcar = GetClosestCar(playerid, carid);
    if(IsPlayerInRangeOfVehicle(playerid, closestcar, 6.0) && IsAMatsCar(closestcar))
    {
    	new engine,lights,alarm,doors,bonnet,boot,objective;
    	GetVehicleParamsEx(closestcar,engine,lights,alarm,doors,bonnet,boot,objective);
    	if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET)
    	{
            SendClientMessageEx(playerid, COLOR_GRAD1, "The vehicle's trunk must be opened in order to search it.");
            return 1;
        }
    	PlayerInfo[playerid][pHeroin] = 1;
    	ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
    	ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
    }
    else
    {
    	SendClientMessageEx(playerid, COLOR_GRAD1, "Ban khong gan mot chiec xe cho vat lieu.");
    }
    return 1;
}



Re: Code error - LuisPark - 05.06.2015

Thanks bro. I got it