Bug trucker - 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: Bug trucker (
/showthread.php?tid=526771)
Bug trucker -
madalin912 - 19.07.2014
Do not go /buyprods
http://s24.postimg.org/m2abuhr2t/sa_mp_036.png
pawn Код:
if(strcmp(cmd, "/buyprods", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new tmpcar = GetPlayerVehicleID(playerid);
new compcost = 50;
if(PlayerToPoint(60.0, playerid, -77.8880,-1136.1812,1.0781))
{
if(IsATruck(tmpcar))
{
if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])
{
new amount;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /buyprods [amount]");
return 1;
}
amount = strval(tmp);
if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_GREY, " Can't buy less then 1 Product or more then 500 !"); return 1; }
new check= PlayerHaul[tmpcar][pLoad] + amount;
if(check > PlayerHaul[tmpcar][pCapasity])
{
format(string, sizeof(string), " You went over the Truck Products Carry Limit of %d, you currently carry %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
new cost = amount*compcost;
if(GetPlayerMoney(playerid) >= cost)
{
PlayerHaul[tmpcar][pLoad] += amount;
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
GivePlayerMoney(playerid,-cost);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
return 1;
}
else
{
format(string, sizeof(string), "You cant afford %d Products at $%d !", amount,cost);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
return 1;
}
}
else
{
format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_LIGHTGREEN, "This Vehicle does not deliver Products.");
return 1;
}
}
}
return 1;
}
Re: Bug trucker -
xVIP3Rx - 19.07.2014
Can you show "IsATruck" stock, I think you didn't put that truck's id there.
Re: Bug trucker -
madalin912 - 19.07.2014
pawn Код:
public IsATruck(carid)
{
if(carid==TRUCK||carid==TRUCK2||carid==TRUCK3||carid==TRUCK4)
{
return 1;
}
return 0;
}
pawn Код:
trucker[0] = AddStaticVehicleEx(524,-54.9980,-1144.3950,1.9599,68.1957,0,0,60000);//166
trucker[1] = AddStaticVehicleEx(524,-53.4792,-1139.7780,2.0346,65.9705,0,0,60000);//167
trucker[2] = AddStaticVehicleEx(524,-67.6936,-1111.7144,2.0096,67.9869,0,0,60000);//168
trucker[3] = AddStaticVehicleEx(524,-51.3282,-1135.2565,2.0075,90.8,0,0,60000);//169
Re: Bug trucker -
xVIP3Rx - 19.07.2014
Look for
pawn Код:
#define TRUCK
#define TRUCK2
#define TRUCK3
#define TRUCK4
Does any of those equal "524" ?
As I think, none of them will equal it, you should add
and add a check too,
pawn Код:
public IsATruck(carid)
{
if(carid==TRUCK||carid==TRUCK2||carid==TRUCK3||carid==TRUCK4||carid==TRUCK5)
{
return 1;
}
return 0;
}
Re: Bug trucker -
madalin912 - 19.07.2014
http://s27.postimg.org/tiluumnz7/sa_mp_037.png
I can not buy the product