/buyseed [Seed] -
Koppa, - 05.06.2009
Can someone give me a example how to do it, I know we would need strtok ro dmcd. but I want to create 3 types:
Код:
1- Cucumber
2- Carrot
3- Tomatoes
Can someone help?
Re: /buyseed [Seed] -
miokie - 05.06.2009
using Dcmd & Sscanf:
pawn Код:
dcmd_BuySeed(playerid, params[])
{
new SeedType;
if(sscanf(params, "d", SeedType)) return SendClientMessage(playerid, ERROR_COLOR, "Usage: /BuySeed [Seed Number]");
else if(SeedType <=0 || SeedType >=4) return SendClientMessage(playerid, ERROR_COLOR,"Choose a valid seed number!");
else if(SeedType == 1)
{
//Do Something
}
else if(SeedType == 2)
{
//Do Something
}
else if(SeedType == 3)
{
//Do Something
}
return 1;
}
UNTESTED.
But something along the lines of that I guess...
Re: /buyseed [Seed] -
Badger(new) - 05.06.2009
using strtok:
pawn Код:
if(strcmp(cmd,"/Buyseed",true)==0)
{
SendClientMessage(playerid,0x00FF00AA,"You need to choose which seed to buy! Choose: /Buy Seed (Seed Number)");
SendClientMessage(playerid,0x00FF00AA,"Seed Types: 1- Cucumber, 2- Carrot, 3- Tomatoes");
tmp=strtok(cmdtext,idx);
if(strcmp(tmp,"1",true)==0)
{
SendClientMessage(playerid,0x00FF00AA,"You have bought Cucumber seeds!");
}
if(strcmp(tmp,"2",true)==0)
{
SendClientMessage(playerid,0x00FF00AA,"You have bought Carrot seeds!");
}
if(strcmp(tmp,"3",true)==0)
{
SendClientMessage(playerid,0x00FF00AA,"You have bought Tomatoes seeds!");
}
return 1;
}
Re: /buyseed [Seed] -
Koppa, - 06.06.2009
Deleted
Re: /buyseed [Seed] -
miokie - 06.06.2009
pawn Код:
dcmd_BuySeed(playerid, params[])
{
new SeedType,SeedAmount,SeedString[50];
if(sscanf(params, "dd", SeedType,SeedAmount)) return SendClientMessage(playerid, 0xFF000096, "* Usage: /BuySeed [Seed Number] [SeedAmount]"); SendClientMessage(playerid, 0xFF000096, "* 1- Cucumber 2- Carrot 3- Tomato");
if(SeedType <= 0 || SeedType >= 4) return SendClientMessage(playerid, 0xFF000096,"Choose a valid seed number!");
else if(SeedType == 1)
{
format(SeedString, sizeof(SeedString),"* You have bought %d Cucumber Seeds!",SeedAmount);
SendClientMessage(playerid, 0x00FF0096, SeedString);
SendClientMessage(playerid, 0x00FF0096, "* Remember: To plant it, you will need to have at least 5 of them.");
FarmInfo[playerid][CucumberSeed] += SeedAmount;
}
else if(SeedType == 2)
{
format(SeedString, sizeof(SeedString),"* You have bought %d Carrot Seeds!",SeedAmount);
SendClientMessage(playerid, 0x00FF0096, SeedString);
SendClientMessage(playerid, 0x00FF0096, "* Remember: To plant it, you will need to have at least 5 of them.");
FarmInfo[playerid][CarrotSeed] += SeedAmount;
}
else if(SeedType == 3)
{
format(SeedString, sizeof(SeedString),"* You have bought %d Tomato Seeds!",SeedAmount);
SendClientMessage(playerid, 0x00FF0096, SeedString);
SendClientMessage(playerid, 0x00FF0096, "* Remember: To plant it, you will need to have at least 5 of them.");
FarmInfo[playerid][TomatoSeed] += SeedAmount;
}
return 1;
}
Forums messed up the indention.
Re: /buyseed [Seed] -
Koppa, - 06.06.2009
Miokie when you were replying I made my command:
http://pastebin.com/m4e77317
But I have one problem: How to set a Timer to the Player to get what he have planted why /plantseed?
Re: /buyseed [Seed] -
miokie - 06.06.2009
SetTimerEx("name",time,0,"i",playerid);
Like that?
Re: /buyseed [Seed] -
Koppa, - 06.06.2009
How to insert a timer I know, but the timer funtion must give the player planted amount Like This:
Код:
public CucumberGrow(playerid)
{
SendClientMessage(playerid, WHITE, " You have received you %d planted cumcumbers seeds");
Variable[playerid] += Received;
}
It's just an example, but is that What I wanna know.
Re: /buyseed [Seed] -
miokie - 06.06.2009
Store the amount planted in a varible, and return the variable in the timer Like:
Varible[playerid] = AmountPlanted[playerid];
Re: /buyseed [Seed] -
Koppa, - 06.06.2009
Like this?
new AmountPlanted[MAX_PLAYERS];
else if(SeedType == 2)
{
format(string, sizeof (string), "You have succesfully planted your %d Carrot Seed(s).", Amount);
SendClientMessage(playerid, 0x00FF0096, string);
AmountPlanted[playerid] += Amount;
Amount = AmountPlanted[playerid];
return 1;
}