|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days. |

06-20-2003, 09:34 AM
|
Sarnak
|
|
Join Date: Apr 2003
Posts: 53
|
|
Added code for random numbers in quests =)
Ok, here it is! :worship:
usage is: $random(x)
where x is the upper limit of a random number 0 < n < x
also, put it in quotes when you use it (ie. givecash("random(10)","random(10)","random(5)","ra ndom(5)"
enjoy!
../zone/parser.cpp : line 1456 (or thereabouts) INSERT this
Code:
//used_pawn
else if (!strcmp(varname,"random")) {
char temp[10];
Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
}
//used_pawn
|

06-21-2003, 08:57 PM
|
Sarnak
|
|
Join Date: Apr 2003
Posts: 53
|
|
bah, i hadnt updated my cvs lately, try putting it here
../zone/parser.cpp : line 1497
Code:
else if (!strcmp(varname,"chr")) {
char temp[4];
memset(temp, 0x0, 4);
temp[0] = atoi(varparms);
Replace(origstring,format,temp);
}
//used_pawn
else if (!strcmp(varname,"random")) {
char temp[10];
Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
}
//used_pawn
else if (!strcmp(varname,"asc")) {
char temp[10];
Replace(origstring,format,itoa(varparms[0],temp,10));
}
Sorry, Im not very good at my postings.
|

06-21-2003, 09:36 PM
|
Demi-God
|
|
Join Date: Jan 2002
Location: Charlotte, NC
Posts: 2,614
|
|
ok.. got it
__________________
Quitters never win, and winners never quit, but those who never win and never quit are idiots.
|

06-22-2003, 08:49 PM
|
Dragon
|
|
Join Date: Jun 2002
Posts: 776
|
|
I've been testing this out and it doesn't seem to use the amount you enter in $random() as the max.
|

06-23-2003, 02:06 AM
|
Discordant
|
|
Join Date: Feb 2003
Posts: 305
|
|
are yoou using $random("10") or $random(10) ?
|

06-23-2003, 05:42 AM
|
Dragon
|
|
Join Date: Jun 2002
Posts: 776
|
|
Tried with both, neither work 100% of the time.
And this is with creating a script to where the npc responds with all of the possible numbers in the quest.
|

06-23-2003, 06:16 AM
|
Discordant
|
|
Join Date: Feb 2003
Posts: 305
|
|
Bleh
Change:
Replace(origstring,format,itoa(rand()%varparms[0],temp,10));
To:
Replace(origstring,format,itoa(rand()%atoi(varparm s[0]),temp,10));
Should maybe do the trick
|

06-23-2003, 02:44 PM
|
Sarnak
|
|
Join Date: Apr 2003
Posts: 53
|
|
the number you put in will never be chosen, that is by design.
as I stated 0<n<x where x is the number you put in random(x), easy to put in one number higher than you need, or change it in the code, doesnt really matter to me either way.
I have noticed strange things with quotes on many commands, some use them, some dont, some dont seem to work the same way twice in a row. Wasnt sure if it was things ive done to my code or if everyone had the problem
ah well, these things happen
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 03:28 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |