Maximum plant slots (drug system) -
denNorske - 14.02.2013
Hello!
I'm currently working on a Drug system for a CnR server, and i am wondering how could i make a limit of 5 plants write to 5 slots ONLY?
Okay, i am using dini to save information about the plants, and it is difficult to save the plants when you leave to only 5 slots, because i don't know how i could do it.
(example)
I have 5 plants planted, which is growing. 1 of the plants is finished growing, and i use a command to harvest it. But, then i want to plant another plant because 1 slot is empty, and the plant which was finished was placed at slot 1, and slot,2,3,4,5 is taken by other plants.
So, how can i "find" the empty slot in the .ini file, and automatically write to that slot? And how can i find out if all the slots are taken in the file and then tell the player that he reached his limit of plants? (because this should be loaded on the OnPlayerConnect, thats why i am wondering)
Any explanation, even just a little example would help alot, because i am
stuck now
Thanks a lot
~Airplanesimen
Re: Maximum plant slots (drug system) -
Babul - 14.02.2013
assuming you already prepared your script for holding some variables, like
Код:
new PlantObject[MAX_PLAYERS][5];//5 plants per player
new PlantPosition[MAX_PLAYERS][5][4];//0,1 and 2= position, 3=rotation(angle)
new PlantGrams[MAX_PLAYERS][5];//not to forget the growed stuff
hence the [], theres a 5 dimensional array storing 5 plants objects&positions in another [3] extra dimensions/per 5 player plants/per player.
i would start with a simple command to plant a seed:
Код:
CMD:plant(playerid,params[]){
SendClientMessage(playerid,-1,"plant command working");
for(new p=0;p<5;p++)
{
if(PlantObject[playerid][p]==0)
{
new Float:pX,Float:pY,Float:pZ,Float:pA;
GetPlayerPos(playerid,pX,pY,pZ);
GetPlayerFacingangle(playerid,pA);
PlantObject[playerid][p]=CreateObject(...,pX,pY,pZ,pA);
PlantPosition[playerid][0]=pX;
PlantPosition[playerid][1]=pY;
PlantPosition[playerid][2]=pZ;
PlantPosition[playerid][3]=pA;
}
}
return 1;
}
...i think no commenting above is required?
anyways, when you think about any limitations like "5 plants per player", its a good idea to prepare for scripting an "endless plants as much the streamer can process".
each plant can be planted by ONE player - pretty obvious. why assign each plant to a player (that [5] limitation), when you can rather assign a player to each plant?
Код:
const PlantsMax=20000;
PlantedByPlayerID[MAX_PLANTS]=playerid;
this got the disadvantage that yuo need to search through all plants, incase you intent to script a /plantGPS...
you got the idea? good. now youll be busy hehe
Re: Maximum plant slots (drug system) -
denNorske - 14.02.2013
Quote:
Originally Posted by Babul
assuming you already prepared your script for holding some variables, like
Код:
new PlantObject[MAX_PLAYERS][5];//5 plants per player
new PlantPosition[MAX_PLAYERS][5][4];//0,1 and 2= position, 3=rotation(angle)
new PlantGrams[MAX_PLAYERS][5];//not to forget the growed stuff
hence the [], theres a 5 dimensional array storing 5 plants objects&positions in another [3] extra dimensions/per 5 player plants/per player.
i would start with a simple command to plant a seed:
Код:
CMD:plant(playerid,params[]){
SendClientMessage(playerid,-1,"plant command working");
for(new p=0;p<5;p++)
{
if(PlantObject[playerid][p]==0)
{
new Float:pX,Float:pY,Float:pZ,Float:pA;
GetPlayerPos(playerid,pX,pY,pZ);
GetPlayerFacingangle(playerid,pA);
PlantObject[playerid][p]=CreateObject(...,pX,pY,pZ,pA);
PlantPosition[playerid][0]=pX;
PlantPosition[playerid][1]=pY;
PlantPosition[playerid][2]=pZ;
PlantPosition[playerid][3]=pA;
}
}
return 1;
}
...i think no commenting above is required?
anyways, when you think about any limitations like "5 plants per player", its a good idea to prepare for scripting an "endless plants as much the streamer can process".
each plant can be planted by ONE player - pretty obvious. why assign each plant to a player (that [5] limitation), when you can rather assign a player to each plant?
Код:
const PlantsMax=20000;
PlantedByPlayerID[MAX_PLANTS]=playerid;
this got the disadvantage that yuo need to search through all plants, incase you intent to script a /plantGPS...
you got the idea? good. now youll be busy hehe
|
Thanks Alot !
You explained pretty well, and thanks!