How transform clasic cmds in zcmd or dcmd?
#1

Hy everyone. I have a problem with 2 commands : /buyprods and /sellprods. Can help me anyone to convert this commands to zcmd dcmd code? Thanks

Код:
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_GRAD1, "USAGE: /buyprods [amount]");
							return 1;
						}
						amount = strval(tmp);
						if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_WHITE, " 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_WHITE, 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, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, 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, TEAM_GROVE_COLOR, string);
							return 1;
						}
					}
					else
					{
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							return 1;
					}
				}
				else
				{
					SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not deliver Products.");
					return 1;
				}
			}
		}
		return 1;
	}
	if(strcmp(cmd, "/sellprods", true) == 0)
	{
	    new cashmade;
	    new tmpcar;
	    if(IsPlayerConnected(playerid))
		{
			tmpcar = GetPlayerVehicleID(playerid);
			if(!IsATruck(tmpcar))
			{
				GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
				return 1;
			}
			if(PlayerHaul[tmpcar][pLoad] == 0)
			{
				GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
				format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
				SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
				return 1;
			}
			for(new i = 0; i < sizeof(BizzInfo); i++)
			{
				if (PlayerToPoint(10, playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
				{
					//printf("Found House :%d",i);
					for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
					{
						if(BizzInfo[i][bProducts] == BizzInfo[i][bMaxProducts])
						{
							GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
						if(BizzInfo[i][bPriceProd] > BizzInfo[i][bTill])
						{
							GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
						PlayerHaul[tmpcar][pLoad]--;
						BizzInfo[i][bProducts]++;
						cashmade = cashmade+BizzInfo[i][bPriceProd];
						ConsumingMoney[playerid] = 1;
						GivePlayerMoney(playerid,BizzInfo[i][bPriceProd]);
						BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
						if(PlayerHaul[tmpcar][pLoad] == 0)
						{
							GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
							format(string, sizeof(string), "Cash Earned $%d.", cashmade);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
							SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
							return 1;
						}
					}
					OnPropUpdate();
					return 1;
				}
			}
		}
		for(new i = 0; i < sizeof(SBizzInfo); i++)
		{
			if (PlayerToPoint(10, playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
			{
				//printf("Found House :%d",i);
				for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
				{
					if(SBizzInfo[i][sbProducts] == SBizzInfo[i][sbMaxProducts])
					{
						GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
					if(SBizzInfo[i][sbPriceProd] > SBizzInfo[i][sbTill])
					{
						GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
					PlayerHaul[tmpcar][pLoad]--;
					SBizzInfo[i][sbProducts]++;
					cashmade = cashmade+SBizzInfo[i][sbPriceProd];
					ConsumingMoney[playerid] = 1;
					GivePlayerMoney(playerid,SBizzInfo[i][sbPriceProd]);
					SBizzInfo[i][sbTill] -= SBizzInfo[i][sbPriceProd];
					if(PlayerHaul[tmpcar][pLoad] == 0)
					{
						GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
						format(string, sizeof(string), "Cash Earned $%d.", cashmade);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
						SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
						return 1;
					}
				}
				OnPropUpdate();
				return 1;
			}
		}
		GameTextForPlayer(playerid, "~r~To Far From A Business", 5000, 1);
		return 1;
	}
Reply
#2

Add this on top of your script

pawn Код:
#include zcmd
Now add this
pawn Код:
COMMAND:buyprods(playerid,params[])
{
        if(IsPlayerConnected(playerid))
        {
                        new tmp[256];
                        new string[256];
            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_GRAD1, "USAGE: /buyprods [amount]");
                            return 1;
                        }
                        amount = strval(tmp);
                        if(amount < 1 || amount > 500) { SendClientMessage(playerid, COLOR_WHITE, " 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_WHITE, 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, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, 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, TEAM_GROVE_COLOR, string);
                            return 1;
                        }
                    }
                    else
                    {
                            format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not deliver Products.");
                    return 1;
                }
            }
        }
        return 1;
    }
COMMAND:sellprods(playerid,params[])
{
        new cashmade;
        new tmpcar;
        if(IsPlayerConnected(playerid))
        {
            tmpcar = GetPlayerVehicleID(playerid);
            if(!IsATruck(tmpcar))
            {
                GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
                return 1;
            }
            if(PlayerHaul[tmpcar][pLoad] == 0)
            {
                GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                return 1;
            }
            for(new i = 0; i < sizeof(BizzInfo); i++)
            {
                if (PlayerToPoint(10, playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
                {
                    //printf("Found House :%d",i);
                    for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
                    {
                        if(BizzInfo[i][bProducts] == BizzInfo[i][bMaxProducts])
                        {
                            GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                        if(BizzInfo[i][bPriceProd] > BizzInfo[i][bTill])
                        {
                            GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                        PlayerHaul[tmpcar][pLoad]--;
                        BizzInfo[i][bProducts]++;
                        cashmade = cashmade+BizzInfo[i][bPriceProd];
                        ConsumingMoney[playerid] = 1;
                        GivePlayerMoney(playerid,BizzInfo[i][bPriceProd]);
                        BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
                        if(PlayerHaul[tmpcar][pLoad] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                    }
                    OnPropUpdate();
                    return 1;
                }
            }
        }
        for(new i = 0; i < sizeof(SBizzInfo); i++)
        {
            if (PlayerToPoint(10, playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
            {
                //printf("Found House :%d",i);
                for(new l = PlayerHaul[tmpcar][pLoad]; l > 0; l--)
                {
                    if(SBizzInfo[i][sbProducts] == SBizzInfo[i][sbMaxProducts])
                    {
                        GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                    if(SBizzInfo[i][sbPriceProd] > SBizzInfo[i][sbTill])
                    {
                        GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                    PlayerHaul[tmpcar][pLoad]--;
                    SBizzInfo[i][sbProducts]++;
                    cashmade = cashmade+SBizzInfo[i][sbPriceProd];
                    ConsumingMoney[playerid] = 1;
                    GivePlayerMoney(playerid,SBizzInfo[i][sbPriceProd]);
                    SBizzInfo[i][sbTill] -= SBizzInfo[i][sbPriceProd];
                    if(PlayerHaul[tmpcar][pLoad] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d/%d.", PlayerHaul[tmpcar][pLoad],PlayerHaul[tmpcar][pCapasity]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                }
                OnPropUpdate();
                return 1;
            }
        }
        GameTextForPlayer(playerid, "~r~To Far From A Business", 5000, 1);
        return 1;
    }
Reply
#3

Thanks man.
Reply
#4

you are welcome
Reply
#5

Little problems:
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67666) : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67666) : error 017: undefined symbol "cmdtext"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67667) : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67672) : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67677) : error 017: undefined symbol "string"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67677) : error 017: undefined symbol "string"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67677) : error 029: invalid expression, assumed zero
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67677) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


8 Errors.
Reply
#6

it's
pawn Код:
#include         <zcmd>
Reply
#7

Add this on "OnPlayerCommandText"
pawn Код:
new cmd[256], string[256];
Reply
#8

CMD:buyprods or COMMAND:buyprods it's not like a public function?

I put new cmd[256] and new string[256]; but I have other errors.

E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67667) : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67667) : error 017: undefined symbol "cmdtext"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(6766 : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67673) : error 017: undefined symbol "tmp"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67657) : warning 204: symbol is assigned a value that is never used: "cmd"
E:\Games\Kituri\SAMP\2010\[[0.3c Final]]GM - 17.01.2011\gamemodes\Coriom.pwn(67721) : warning 204: symbol is assigned a value that is never used: "cmd"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

no not there
Put this on your commands
pawn Код:
new string[256];
pawn Код:
new cmd[256];
Reply
#10

It's a command which can be worked as an apart function, therefore it MUST NOT be in any callback (ex: OnPlayerCommandText)

By the way don't listen to Ironboy, he yet doesn't know that strings HAVE NOT to be 256 sized.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)