Jump to content

ToastOfDoom

Members
  • Content Count

    44
  • Avg. Content Per Day

    0
  • Joined

  • Last visited

  • Days Won

    2

ToastOfDoom last won the day on December 13 2012

ToastOfDoom had the most liked content!

Community Reputation

48 Excellent

About ToastOfDoom

  • Rank
    Drops

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

3,827 profile views
  1. @Patskie You want to use a variable with the getarraysize value as opposed to calling the function directly inside the for loop. prontera,150,150,0 script Sample 100,{ for ( [email protected] = 0; [email protected] < .num_r; [email protected] += 2 ) { if ( countitem( .r[ [email protected] ] ) < .r[ [email protected] + 1 ] ) { mes "Lack of requirements"; close; } } for ( [email protected] = 0; [email protected] < .num_r; [email protected] += 2 ) delitem .r[ [email protected] ], .r[ [email protected] + 1 ]; for ( [email protected] = 0; [email protected] < .num_p; [email protected] += 2 ) getitem .p[ [email protected] ], .p[ [email protected] + 1 ]; mes "Nice!"; close; OnInit: // item id, amount ( r = requirements | p = prize ) setarray .r[0],7227,5,7179,5; setarray .p[0],1202,1,5013,1; set .num_r, getarraysize(.r); set .num_p, getarraysize(.p); end; } The getarraysize() function quite literally goes through the array checking if each value exists till the end. To put it in a loop like that means the processing time will increase quadratically as you add items. static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isstring, struct DBMap** ref) { int32 ret = idx; if( isstring ) { for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx ) { char* str = (char*)get_val2(st, reference_uid(id, idx), ref); if( str && *str ) ret = idx + 1; script_removetop(st, -1, 0); } } else { for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx ) { int32 num = (int32)__64BPRTSIZE(get_val2(st, reference_uid(id, idx), ref)); if( num ) ret = idx + 1; script_removetop(st, -1, 0); } } return ret; }
  2. The function you supply with the 'function' function needs to return 'true' (or something that the scripting engine that fulfills a true condition). I believe this means anything that isn't 0 or an empty string. Likewise the same applies to the flag function as well. Easiest way to check if(<variable name>) dispbottom "true"; else dispbottom "false";
  3. @Euphy =O!! You broke my controller? =( Sigh..now i have to make an update... Might as well make it awesomener while i'm at it....
  4. You're comparing a number with a string if([email protected]_parameters$[0] != 30){ needs to be if([email protected]_parameters$[0] != "30"){ You shouldn't really use useatcmd but instead redefine all the @go warp points in the scripting code. You should only use that command if it's not possible to replicate the existing @command function using script. In this case warping a player is very easily done. Also next time please post the error you get in the mapserver as well as your code. Just saying "give's an error in mapserver" doesn't tell us much.
  5. @ryokem Feefty said it was for their daily quest script. Of course I have no way to be sure but its perfectly reasonable for me to guess what they are using it for and to provide suggestions based upon that. There's no reason you should be shutting down someone's suggestions like this. It just locks out 'out of the box' suggestions which doesn't help anyone at all. There's not too many instances where you really do need to set all of a certain # var at a certain time. Like you can't even use the var if the player is offline. @lighta Using gettimetick(2) / 86400 will give a 'day tick' using epoch time. Will work till like 2036. I can't remember if it uses UTC time or server time though...
  6. You could always model the data differently. Eg. Lets say you have a quest you want players to do only once every day. You could: a. Check for a variable every time they do the quest. If it is set then they've done it already and don't let them do the quest. Reset every variable at midnight. OR b. Set a variable with the date everytime they do the quest. Then check using that variable that it's been at least 1 day before they do the quest.(no messy super reset using sql)
  7. Don't think i'll get around to actually writing the script but here is the model i'll use for calculating if a player had won. Don't read if you still want to think about it and figure out your own method.
  8. @annie They mean you only get a PVP point if you haven't already killed them today. So you kill them the 1st time and you get a point. If you kill them a 2nd time you don't get a point unless it's been 24hrs since you last killed that person. @serakh00 If you want us to optimise your system you need to post your script and work.
  9. How about implementing some kind of 'virtual' player. The player can be shared between NPCs and all existing player modification functions can be used. Used something like this... [email protected]_gid = CreateVirtualPlayer(); attachrid([email protected]_gid); statusup2(bStr, 100); UseSkillToPC([email protected]_gid, <skill_id>, <skill_level>, <target_gid>); UseSkillToPC([email protected]_gid, <skill_id>, <skill_level>, <map>, <x>, <y>); DestroyVirtualPlayer([email protected]_gid); Casting source can be set to the invoking NPC or nothing in the case of Floating NPCs.
  10. @ryokem There is a trick where if you leave a menu item blank, it won't show, but it will still use up the index. if ( [email protected] ) [email protected]$[0] = "Previous Page"; In this case the first page actually looks something like this ":<item1>:<item2>:<item3>:Next Page" Note that it starts with a colon ':'. This means index 1 (adjusted to be 0 later) will always correspond to 'Previous Page' regardless of wherever it is shown or not. Likewise the same thing happens for the 'Next Page' item only with a different index. This method cuts down on alot of extra math, loops and comparisons. However it leaves a security flaw in that players can possibly get to non wanted menus through packet manipulation. Therefore scripters will need to do further checks in their script after the menu selection depending on the usage to insure that selection is valid.
  11. @annie Looking good =D. Yours definitely runs better. I think if you Put the next/previous lines into the tmp$ array and crunch it all with implode at the End It would make it extra sexy. tmp$[0] = previous page; tmp$[.items_per_page + 1] = next page; Ps: on phone atm so cant script. ^^;
  12. Couldn't we change it so if the MOTD is blank it just wouldn't show. That way if a user requires a more advanced MOTD they can disable the existing implementation still add their own thing using OnPCLoginEvent. Having a script reference directly hardcoded into source feels very weird for me.
  13. you can already do this using a combination of getd and setarray. setarray getd(".test[0]"), 1, 2, 3, 4, 5; Also sorry for the necro... =P
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.