Percent on planting -
Zens - 24.04.2014
Hello,
I need some help scripting a weed plant system with percentages.
I've added 5 different sorts of weed, now I need some help adding them into the plant system.
The normal plant is already implentet, it works fine and gives regular low quality skunk. I need some help adding a percent system, here's an example of what I need:
EXAMPLE:
You plant some seeds and the plant will randomly pick one of the 5 sorts based on the percentages.
50 percent chance of getting pot.
20 percent change of getting Skunk.
15 percent chance of getting Super Skunk.
10 percent change of getting Bubblegum Skunk.
5 percent chance of getting AK-47 Skunk.
Note; I'm using ZCMD.
AW: Percent on planting -
Nero_3D - 24.04.2014
pawn Код:
switch(random(100)) {
case 0..4: {} // AK-47
case 5..14: {} // Bubblegum
case 15..29: {} // Super
case 30..49: {} // Skunk
default: // pot
}
You could put the ranges anywhere into the 100 and leave the rest for the pot
But that should give you a good idea how it should look
Re: AW: Percent on planting -
Zens - 24.04.2014
Quote:
Originally Posted by Nero_3D
pawn Код:
switch(random(100)) { case 0..4: {} // AK-47 case 5..14: {} // Bubblegum case 15..29: {} // Super case 30..49: {} // Skunk default: // pot }
You could put the ranges anywhere into the 100 and leave the rest for the pot
But that should give you a good idea how it should look
|
Thanks a lot for answering.

Should I add the switch under /plant or /pick?
AW: Percent on planting -
Nero_3D - 24.04.2014
Well I think you should put it in /pick because the plant always looks the same
Otherwise you would need to store the value till it gets picked
Re: AW: Percent on planting -
Zens - 24.04.2014
pawn Код:
CMD:pickweed(playerid,params[])
{
for(new i = 0; i < MAX_WEED; i++)
{
if(!IsPlayerInRangeOfPoint(playerid,2.5,winfo[i][poswx],winfo[i][poswy],winfo[i][poswz]-1)) continue;
if(winfo[i][finished] == 0) return SendClientMessage(playerid,-1,"Your weed is not fully grown yet.");
if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,-1,"You need to be on foot to pick your weed.");
DestroyDynamicObject(mariaobject[i]);
DestroyDynamic3DTextLabel(winfo[i][labelweed]);
pinfo[playerid][weed] = pinfo[playerid][weed] + 5;
limit--;
}
return 1;
}
How can I possibly add it to the command and do I need to define it anywhere?
AW: Percent on planting -
Nero_3D - 25.04.2014
Just put it at the end of the command
pawn Код:
CMD:pickweed(playerid, params[]) {
if(GetPlayerVehicleID(playerid)) {
return SendClientMessage(playerid,-1,"You need to be on foot to pick your weed.");
}
new
i = -1
;
while(++i < MAX_WEED) {
if(IsPlayerInRangeOfPoint(playerid,2.5,winfo[i][poswx],winfo[i][poswy],winfo[i][poswz]-1)) {
break;
}
}
if(i == MAX_WEED) {
return SendClientMessage(playerid,-1,"You need to be next to a fully grown weed.");
}
if(winfo[i][finished] == 0) {
return SendClientMessage(playerid,-1,"Your weed is not fully grown yet.");
}
switch(random(100)) {
case 0..4: {} // AK-47
case 5..14: {} // Bubblegum
case 15..29: {} // Super
case 30..49: {} // Skunk
default: pinfo[playerid][weed] = pinfo[playerid][weed] + 5;
}
DestroyDynamic3DTextLabel(winfo[i][labelweed]);
DestroyDynamicObject(mariaobject[i]);
limit--;
return true;
}
Re: Percent on planting -
Zens - 25.04.2014
Thanks a lot!
I've been trying to add clientmessages which will show which sort they will receive, but it seems like it's failing on this one:
pawn Код:
default: PlayerInfo[playerid][pPot] +=20 && SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have harvested your plant and received 20 grams of regular pot."); // Pot
It sends the client message, but it only adds 1 gram of pot instead of 20... It works fine without the clientmessage.
How can I possibly add client messages at each case?
Re: Percent on planting -
Zens - 28.04.2014
bump
AW: Percent on planting -
Macronix - 28.04.2014
pawn Код:
default: { PlayerInfo[playerid][pPot] +=20; SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have harvested your plant and received 20 grams of regular pot."); } // Pot