SA-MP Forums Archive
Feed Cow Problem :) - 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: Feed Cow Problem :) (/showthread.php?tid=598457)



Feed Cow Problem :) - Mikeydoo - 12.01.2016

Heey guys! Working on a cow raise script and sell by the pound at the 24/7.

Hum I got a problem with feeding it now. Note : I am ready to offer 5$ to anyone who helps me with it.

I want the command to check the player cow lbs, and add 5 to it.

Код:
if(PlayerInfo[playerid][pCow][i]) format(string, sizeof(string), "%d) %d lbs.", i+1, PlayerInfo[playerid][pCow][i]);
Here is the Buycow command I made :
Код:
CMD:buycow(playerid, params[])
{
	new string[128], done, cow;
   	if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
 	if(!IsAtAnimalCenter(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the Animal Center.");
	if(CowTime[playerid])
	{
	    format(string, sizeof(string), "You need to wait %d more seconds before buying a new cow.", CowTime[playerid]);
		SendClientMessage(playerid, COLOR_GREY, string);

	    return 1;
	}
	for(new i=0; i<2; i++) // Cows
	{
	    if(!done)
	    {
		    if(!PlayerInfo[playerid][pCow][i]) done = i+1;
	    }
	}
	if(!done) return SendClientMessage(playerid, COLOR_GREY, "You can't have any more cows.");
	done = done-1;
	// Buying different cow sizes
	if(strval(RPJL(playerid, JOB_FARMER)) == 1) cow = random(10)+5;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 2) cow = random(20)+15;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 3) cow = random(40)+20;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 4) cow = random(60)+25;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 5) cow = random(80)+40;
	PlayerInfo[playerid][pCow][done] = cow;
	format(string, sizeof(string), "* %s Buys a new born cow at the Animal Center.", RPN(playerid));
 	SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	format(string, sizeof(string), " Your new born cow is a %d lbs cow.", cow);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	// Leveling
    new oldj = strval(RPJL(playerid, JOB_FARMER));
    PlayerInfo[playerid][pJobSkill][JOB_FARMER] ++;
	new newj = strval(RPJL(playerid, JOB_FARMER));
    if(oldj < newj)
	{
	    format(string, sizeof(string), "** Your Farmer level is now %d, you can now buy heavier cows. **", newj);
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	CowBought[playerid] ++;
	if(CowBought[playerid] >= 5)
	{
	    format(string, sizeof(string), " Remember to feed your cow to make it grow ! ", cow);
	    format(string, sizeof(string), " For more info on cows use /Cowhelp ", cow);
		CowBought[playerid] = 0;
		CowTime[playerid] = 5;
		SetTimerEx("CowBuyTime", 1000, true, "i", playerid);
	}
	return 1;
}
Heres the command that checks your cows
Код:
CMD:cows(playerid, params[])
{
	new string[128];
    SendClientMessage(playerid, COLOR_BLUE, "____________________________");
	SendClientMessage(playerid, COLOR_WHITE, "   *** Your Cows ***");
	for(new i=0; i<1; i++)
	{
		if(PlayerInfo[playerid][pCow][i]) format(string, sizeof(string), "%d) %d lbs.", i+1, PlayerInfo[playerid][pCow][i]);
		else format(string, sizeof(string), "%d) None.", i+1);
		SendClientMessage(playerid, COLOR_WHITE, string);
	}
	return 1;
}
I don't know what kind of syntax to use i'm sooo confused.

Any help is highly appreciated and of course if you need more code I'll be more than happy to paste it.


Re: Feed Cow Problem :) - -CaRRoT - 13.01.2016

I am sorry but I am a bit lost here, are you trying to add 5 more cows or 5 more pounds when you sell?


Re: Feed Cow Problem :) - Mikeydoo - 13.01.2016

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
I am sorry but I am a bit lost here, are you trying to add 5 more cows or 5 more pounds when you sell?
5 more pounds sorry I should have precised.


Re: Feed Cow Problem :) - -CaRRoT - 13.01.2016

Quote:
Originally Posted by Mikeydoo
Посмотреть сообщение
5 more pounds sorry I should have precised.
So 5 more pounds when you /buycows ?


Re: Feed Cow Problem :) - Mikeydoo - 13.01.2016

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
So 5 more pounds when you /buycows ?
5 more pounds when you use /feedcow

I tried to make the command but it just doesnt feel right Its incomplete and i dont know where to start.. heres what i started and got stuck at

Код:
CMD:feedcow(playerid, params[])
{
	new string[128];
	if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
	if(sscanf(params, "i", cow)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /feedcow [cow slot]");
	if(cow < 1 || cow > 2) return SendClientMessage(playerid, COLOR_GREY, "Cows are between 1 and 2.");
        {
	}
	return 1;
}
Edit : So i'm thinking of making the script get the cow lbs and add 5lbs to it. but i dont know the correct syntax and all ..


Re: Feed Cow Problem :) - -CaRRoT - 13.01.2016

Well, since I am not very familiar with your variables, Your /buycow command just gives/adds a random amount of pounds to your pCow variable[so that variable supposedly represents the amount of pounds the cow is ?]

Код:
	if(strval(RPJL(playerid, JOB_FARMER)) == 1) cow = random(10)+5;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 2) cow = random(20)+15;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 3) cow = random(40)+20;
	else if(strval(RPJL(playerid, JOB_FARMER)) == 4) cow = random(60)+2else if(strval(RPJL(playerid, JOB_FARMER)) == 5) cow = random(80)+40;
	PlayerInfo[playerid][pCow][done] = cow;
So basically all you'll need to do is to add 5 more to your pCow variable within your command, something like this

Код:
PlayerInfo[playerid][pCow] = PlayerInfo[playerid][pCow] += 5;
Unless I got your variables wrong.


Re: Feed Cow Problem :) - Mikeydoo - 13.01.2016

Yes the buycow command is giving the item cow to the player and setting its weight to a random value. ( depending on player job level )

I'm not sure if using your line its going to select the cow slot tho

let me try ^^

Edit : oh and i must have a line that looks if the player have a cow or not before using that line
Do you mind telling me how ?


Re: Feed Cow Problem :) - -CaRRoT - 13.01.2016

Quote:
Originally Posted by Mikeydoo
Посмотреть сообщение
Yes the buycow command is giving the item cow to the player and setting its weight to a random value. ( depending on player job level )

I'm not sure if using your line its going to select the cow slot tho

let me try ^^

Edit : oh and i must have a line that looks if the player have a cow or not before using that line
Do you mind telling me how ?
No it wouldn't, that line will only add 5 more to your pCow variable which should be the pounds as far as I understand.


Re: Feed Cow Problem :) - Mikeydoo - 13.01.2016

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
No it wouldn't, that line will only add 5 more to your pCow variable which should be the pounds as far as I understand.
Yes it should but as the command is written like this
Код:
	if(sscanf(params, "i", cow)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /feedcow [cow slot]");
should it not select a cow slot ?

Im so confused

Thanks for helping by the way


Re: Feed Cow Problem :) - -CaRRoT - 13.01.2016

Yea for sure, glad I could help!