Jump to content
  • 0

problema la /buyprods


cr3azy

Question

am problema la /buyprods cand dau imi zice ca serverul nu recunoaste comanda

if(strcmp(cmd, "/buyprods", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
			new tmpcar = GetPlayerVehicleID(playerid);
			new compcost = 50;
			if(PlayerToPoint(60.0, playerid, -78.9067,-1130.7458,0.6489))//2787.8,-2436.3,13.7
			{
				if(IsATruck(tmpcar))
				{
				    if(IsTrailerAttachedToVehicle(tmpcar))
				    {
						if(PlayerHaul[GetVehicleTrailer(tmpcar)][pLoad] < PlayerHaul[GetVehicleTrailer(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[GetVehicleTrailer(tmpcar)][pLoad] + amount;
							if(check > PlayerHaul[GetVehicleTrailer(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[GetVehicleTrailer(tmpcar)][pLoad] += amount;
								format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[GetVehicleTrailer(tmpcar)][pLoad],PlayerHaul[GetVehicleTrailer(tmpcar)][pCapasity]);
								SendClientMessage(playerid, COLOR_GREEN, string);
								format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
								SendClientMessage(playerid, COLOR_GREEN, 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_GREEN, string);
								return 1;
							}
						}
						else
						{
								format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[GetVehicleTrailer(tmpcar)][pLoad],PlayerHaul[GetVehicleTrailer(tmpcar)][pCapasity]);
								SendClientMessage(playerid, COLOR_GREEN, string);
								return 1;
						}
					}
					else SendClientMessage(playerid, COLOR_GRAD1, " * Trebuie sa-ti cuplezi mai intai remorca");
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "This Vehicle does not deliver Products.");
					return 1;
				}
			}
		}
		return 1;
	}

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Incearca cu aceasta comanda :

[pawn] if(strcmp(cmd, "/buyprods", true) == 0)

{

    if(IsPlayerConnected(playerid))

{

new tmpcar = GetPlayerVehicleID(playerid);

new compcost = 50;

if(PlayerToPoint(60.0, playerid, 2787.8,-2436.3,13.7))

{

if(IsATruck(tmpcar))

{

if(PlayerHaul[tmpcar][pLoad] < PlayerHaul[tmpcar][pCapasity])

{

    new amount;

    tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, COLOR_LIGHTRED, "» Foloseste: {FFFFFF}/buyprods [amount]");

return 1;

}

amount = strval(tmp);

if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_GREY, "Poti cumpara doar intre 1 si 100 de produse!"); return 1; }

new check= PlayerHaul[tmpcar][pLoad] + amount;

if(check > PlayerHaul[tmpcar][pCapasity])

{

    format(string, sizeof(string), "Ai avut produse peste limita %d, acuma ai %d.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pLoad]);

    SendClientMessage(playerid, COLOR_GREY, string);

    return 1;

}

new cost = amount*compcost;

if(GetPlayerCash(playerid) >= cost)

{

PlayerHaul[tmpcar][pLoad] += amount;

format(string, sizeof(string), "Produse: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);

SendClientMessage(playerid, TEAM_GROVE_COLOR, string);

format(string, sizeof(string), "Ai cumparat %d produse si ai platit $%d.", amount,cost);

SendClientMessage(playerid, TEAM_GROVE_COLOR, string);

GivePlayerCash(playerid,-cost);

PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);

return 1;

}

else

{

format(string, sizeof(string), "Nu iti permiti %d produse la suma de $%d!", amount,cost);

SendClientMessage(playerid, TEAM_GROVE_COLOR, string);

return 1;

}

}

else

{

format(string, sizeof(string), "Produse: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);

SendClientMessage(playerid, TEAM_GROVE_COLOR, string);

return 1;

}

}

else

{

SendClientMessage(playerid, TEAM_GROVE_COLOR, "Acesta masina nu este un tir de livrare produse.");

return 1;

}

}

}

return 1;

}

[/pawn]

Culori in caz ca iti da eroare la compilare :

[pawn]

#define COLOR_GREY 0xAFAFAFAA

#define TEAM_GROVE_COLOR 0x00D900C8

[/pawn]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.