Code don't work!
#1

Hello,
I created an truckdriver job. The truckdrivers have to deliver a trailer at the docks. But i have some problems with the checkpoint:
Код:
public OnPlayerEnterCheckpoint(playerid)
{
	new vehicleid;
	new vehicle;
	vehicle = GetPlayerVehicleID(playerid);
	if (vehicle == 403) // linerunner id
	{
  	if(IsTrailerAttachedToVehicle(vehicleid))
		{
			GivePlayerMoney(playerid, 800);
			SendClientMessage(playerid, 0xAFAFAFAA,"You have deliver your trailer succesfully, you get 800 dollar for it");
			return 1;
		}
		else
		{
			SendClientMessage(playerid, 0xAFAFAFAA,"You're not in a truck!");
			return 1;
		}}}
Does anybody know how to make it work?
Reply
#2

Hmm, I've seen A LOT of people make this mistake.

GetPlayerVehicleID doesn't get the model ID, which is what your using, it gets the vehicle ID as per the script. (Example: The first car to be created = 1.)

Use GetVehicleModel as well, before saving it to a variable.

https://sampwiki.blast.hk/wiki/GetVehicleModel

Example:

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new vehicleid;
    new vehicle;
    vehicleid = GetPlayerVehicleID(playerid);
    vehicle = GetVehicleModel(vehicleid);

    if (vehicle == 403) // linerunner id
    {
        if(IsTrailerAttachedToVehicle(vehicleid))
        {
            GivePlayerMoney(playerid, 800);
            SendClientMessage(playerid, 0xAFAFAFAA,"You have deliver your trailer succesfully, you get 800 dollar for it");
            return 1;
        }
        else
        {
            SendClientMessage(playerid, 0xAFAFAFAA,"You're not in a truck with a trailer!");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, 0xAFAFAFAA,"You're not in a truck!");
        return 1;
    }
}
Reply
#3

Thank you, it works! But now you can drive in every checkpoint with a truck to receive money. Is there a way to make this impossible? (I have 1 cp on the docks where the trucks must go)
Reply
#4

hmm
Reply
#5

You must be using a streamer, yes? By default, you can only have 1 active checkpoint in SA:MP without one, which one are you using, and if not, get one, that will solve your problems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)