SA-MP Forums Archive
How To Fix This 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: How To Fix This Error (/showthread.php?tid=356410)



How To Fix This Error - God'Z War - 03.07.2012

Hi Guys,
i have made an repair vehicle on pickup when i enter to server and i stand with vehicle but it didnt repair
This is the code
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    switch (pickupid)
    {
//-----------------------Vehicle Repair----------------
        case 0:
        {
        RepairVehicle(GetPlayerVehicleID(playerid));
        SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        SendClientMessage(playerid,orange,"Vehicle Fixed");
    return 1;
}
Plz Help me To Fix This Problem


Re: How To Fix This Error - .FuneraL. - 03.07.2012

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    switch (pickupid)
    {
//-----------------------Vehicle Repair----------------
        case 0:
        {
        RepairVehicle(GetPlayerVehicleID(playerid));
        SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        SendClientMessage(playerid,orange,"Vehicle Fixed");
        }
    }
    return 1;
}
Try This.


Re: How To Fix This Error - God'Z War - 03.07.2012

Oh Sorry .FuneraL.
there is no need to add
Quote:

}
}
return 1;
}

Because its continues Like
pawn Код:
case 0:
        {
        RepairVehicle(GetPlayerVehicleID(playerid));
        SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        SendClientMessage(playerid,orange,"Vehicle Fixed");
        }
//-----------------------Weapons-----------------------
        case 1:
        {



Re: How To Fix This Error - .FuneraL. - 03.07.2012

Try then using the ID's of the pickup's, Only example:

pawn Код:
if(pickupid == PICKUP1)
{
     // Their Functions
}



Re: How To Fix This Error - iggy1 - 03.07.2012

Well it's not working because pickupid 0 does not exist. I think ids start from 1.

You should use an if statement and check it against a pickup id.

pawn Код:
new some_pickup;//global

//put this wherever you create the pickup:
some_pickup = CreatePickup(...);

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == some_pickup)
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        SendClientMessage(playerid,orange,"Vehicle Fixed");
    }
    return 1;
}
EDIT: A bit too slow.