Help With C++ Coding.
Okay thanks, and what about for this question?
// Weapon Drop:
// 1.4% chance Valuable Drop 60% that it is a Weapon
if (iDice(1,10000) <= 6000) {
if (iDice(1,10000) <= 8000) {
// 70% the Weapon is Melee
do I just manaully change the percentages if i want to higher then chance rate of a valuable drop??
If I change the 1.4 percentage to say 25%, do I gotta change the if statement (1,10000) to like (2500/10000)?
// Weapon Drop:
// 1.4% chance Valuable Drop 60% that it is a Weapon
if (iDice(1,10000) <= 6000) {
if (iDice(1,10000) <= 8000) {
// 70% the Weapon is Melee
do I just manaully change the percentages if i want to higher then chance rate of a valuable drop??
If I change the 1.4 percentage to say 25%, do I gotta change the if statement (1,10000) to like (2500/10000)?
Okay theres some serious issues here.
I try and compile it when I edit the name and drop number, the compiler says theres too many errors and it stops
So I try compiling again, this time with absolutely nothing changed, the same 2.24b game.cpp that I downloaded.
It still says too many errors...wtf?
I tried with 2.20 source files too and it gave me error messages too.
Even when I dont change anything I still get the messages....help? btw I'm using dev compiler.
I try and compile it when I edit the name and drop number, the compiler says theres too many errors and it stops
So I try compiling again, this time with absolutely nothing changed, the same 2.24b game.cpp that I downloaded.
It still says too many errors...wtf?
I tried with 2.20 source files too and it gave me error messages too.
Even when I dont change anything I still get the messages....help? btw I'm using dev compiler.
No the iDice method doesn't work that way.Ghaleon wrote: Okay thanks, and what about for this question?
// Weapon Drop:
// 1.4% chance Valuable Drop 60% that it is a Weapon
if (iDice(1,10000) <= 6000) {
if (iDice(1,10000) <= 8000) {
// 70% the Weapon is Melee
do I just manaully change the percentages if i want to higher then chance rate of a valuable drop??
If I change the 1.4 percentage to say 25%, do I gotta change the if statement (1,10000) to like (2500/10000)?
Basically the parameters of iDice are as follows (there are two):
The first is the number of dices you want to "throw".
The second is the number of eyes on each dice.
So iDice(2500, 10000); will roll 2500 dices that can result in 1 to 10000 and sum each result up.
If you want to have a 25% chance of drop then you should throw one four-sided dice (4 eyes):
if (iDice(1, 4) == 1) { // 25% percent chance of succeeding.
}
However. The iDice algorithm is a recursive one. It's not really good (in my opinion) in this case. A better solution is:
if (!(rand() % 4)) { // chance of 25% that this if-block is executed.
}
if (!(rand() % 100)) { // chance of 1/100 (that's 0.01%) that this if-block is executed.
Hope this helps!
Here is a nice method for easy usage.
Just add the following to wmain.cpp and add "extern bool chanceSuccess(double dPercentage);" to CGame.h outside the class-block.
You can then use it by simply using:
if (chanceSuccess(25)) {
// This part is executed 25% of the time.
// When you execute it a 1000 times with a PutLogList()
// function, it will print it about 250 times (theoretically).
}
Just add the following to wmain.cpp and add "extern bool chanceSuccess(double dPercentage);" to CGame.h outside the class-block.
Code: Select all
bool chanceSuccess(double dPercentage); // function header
/* param: dPercentage = The chance of succes (from 0 to 100).
Returns False when the calculation wasn't succesful this time (bad luck).
Returns True when the calculation was succesful (good luck). */
bool chanceSuccess(double dPercentage) {
return (!(rand() % (100 / dPercentage)));
}
if (chanceSuccess(25)) {
// This part is executed 25% of the time.
// When you execute it a 1000 times with a PutLogList()
// function, it will print it about 250 times (theoretically).
}
Ok I tried it now with microsoft visual c++ 6.0
I still get errors...these are just some..
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49584) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2501: 'pItem' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2086: 'pItem' : redefinition
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2065: 'm_pNpcList' : undeclared identifier
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2065: 'iNpcH' : undeclared identifier
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2227: left of '->m_cMapIndex' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2501: 'm_pMapList' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49593) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49593) : error C2227: left of '->m_cMapIndex' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2227: left of '->m_sX' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2227: left of '->m_sY' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_sSprite' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_sSpriteFrame' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_cItemColor' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2501: 'SendEventToNearClient_TypeB' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49598) : error C2501: '_bItemLog' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49598) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49600) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49600) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49603) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49603) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Game.obj - 53 error(s), 5 warning(s)
I still get errors...these are just some..
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49584) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2501: 'pItem' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2086: 'pItem' : redefinition
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49585) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2065: 'm_pNpcList' : undeclared identifier
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2065: 'iNpcH' : undeclared identifier
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2227: left of '->m_cMapIndex' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2501: 'm_pMapList' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49588) : error C2143: syntax error : missing ';' before '->'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49593) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49593) : error C2227: left of '->m_cMapIndex' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2227: left of '->m_sX' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49594) : error C2227: left of '->m_sY' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_sSprite' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_sSpriteFrame' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2227: left of '->m_cItemColor' must point to class/struct/union
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2501: 'SendEventToNearClient_TypeB' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49595) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49598) : error C2501: '_bItemLog' : missing storage-class or type specifiers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49598) : error C2078: too many initializers
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49599) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49600) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49600) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49603) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\Andrew.GLEN-JC61D7U161\Desktop\Source\2.24b Sources\Game.cpp(49603) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Game.obj - 53 error(s), 5 warning(s)
lol@errors. You're just making too many noob errors (no offense). I mean noob errors like
error C2143: syntax error : missing ';' before '->'
error C2086: 'pItem' : redefinition
and ALL the undeclared identifiers.
Easy fix? Get someone who knows c++ to help you. It's not as easy as just downloading c++ sources and copy pasting. Some people can do it, yes, but believe it or not, you can't just copy any section you want, paste it, and have it compile properly. You're better off sticking with iDice if you don't know how to add functions. It appears like you either put too many }'s, or missed a WHOLE LOT of ;'s. Check over your code.. Every line of code (except }) has to end in ;.
error C2143: syntax error : missing ';' before '->'
error C2086: 'pItem' : redefinition
and ALL the undeclared identifiers.
Easy fix? Get someone who knows c++ to help you. It's not as easy as just downloading c++ sources and copy pasting. Some people can do it, yes, but believe it or not, you can't just copy any section you want, paste it, and have it compile properly. You're better off sticking with iDice if you don't know how to add functions. It appears like you either put too many }'s, or missed a WHOLE LOT of ;'s. Check over your code.. Every line of code (except }) has to end in ;.
<img src='http://www.helbreathx.net/sig/sig.jpeg' border='0' alt='user posted image' /><br><a href='http://mafia.cheats4us.org/index.php?x=231030' target='_blank'>#1 on Mafia </a><br><!--QuoteBegin-Slipknight+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Slipknight)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->100mb Internet, burstable too 10GB oc192<br>his speed can go up too 10gbs<br>...<br>Yes my car can have a top speed of 1000mph<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br>^^ I wonder where the retard went to.