Code don't work! - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Code don't work! (
/showthread.php?tid=119975)
Code don't work! -
sean5874 - 10.01.2010
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?
Re: Code don't work! -
spartan1178 - 10.01.2010
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;
}
}
Re: Code don't work! -
sean5874 - 10.01.2010
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)
Re: Code don't work! -
Brian_Furios - 10.02.2010
hmm
Re: Code don't work! -
spartan1178 - 10.02.2010
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.