943,589 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3446
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 27th, 2006
0

Script problem help

Expand Post »
Id like someone to take a look at this piece of code and tell me any errors to correct, ms-vc++ 6.0 says there are 3, but when I correct them it creates more errors (example being: going from 3 errors to 18 with one ';' going in)
Help appreciated.
Here is the code:

C++ Syntax (Toggle Plain Text)
  1. // --------------------- Database Management Library ---------------------------------
  2. // Do not modify this.
  3.  
  4. function script func_searchdb {
  5. set $@array_size, getarraysize(getarg(0));
  6. for(set $@db_count, 0; $@db_count < $@array_size; set $@db_count, $@db_count + 1){
  7. if(getelementofarray(getarg(0), $@db_count) == getarg(1))
  8. return $@db_count;
  9. }
  10. return -1;
  11. }
  12.  
  13. function script func_addentry {
  14. if(getarraysize(getarg(0)) < 127) {
  15. if(getarg(0) != 0)
  16. set getelementofarray(getarg(0), getarraysize(getarg(0))), getarg(1);
  17. else
  18. set getarg(0), getarg(1);
  19. return 0;
  20. }
  21. return 1;
  22. }
  23.  
  24. function script func_removeentry {
  25. set $@re_entry, callfunc("func_searchdb", getarg(0), getarg(1));
  26. if($@re_entry != -1)
  27. deletearray getelementofarray(getarg(0),$@re_entry),1;
  28. return;
  29. }
  30.  
  31. // --------------------------- Core Function -----------------------------------------
  32. // Do not modify this.
  33.  
  34. function script func_soundall {
  35. set $@rid_backup, playerattached();
  36. for(set $@dbe_cnt2, 0; $@dbe_cnt2 < $@rid_dbe_num; set $@dbe_cnt2, $@dbe_cnt2+1) {
  37. set $@database_name$, getarg(0) + $@dbe_cnt2;
  38. set $@array_size, getarraysize(getd($@database_name$));
  39. for(set $@sa_count, 0; $@sa_count < $@array_size; set $@sa_count, $@sa_count + 1){
  40. if(attachrid(getelementofarray(getd($@database_name$), $@sa_count)) != 0)
  41. soundeffect getarg(1), 0;
  42. }
  43. }
  44. attachrid $@rid_backup;
  45. return;
  46. }
  47.  
  48. // --------------------------- Database Handler --------------------------------------
  49. // Modify according to your needs.
  50. - script database_handler -1,{
  51. end;
  52.  
  53. OnInit:
  54. // The base database name
  55. set $@rid_database_name$, "$@rid_database_";
  56. // The maximum number of database to allocate
  57. // Adjust this to your needs, each database is capable of holding 127 players.
  58. set $@rid_dbe_num,;
  59. end;
  60.  
  61. }
  62.  
  63. // ------------------------ Login/Logout Events --------------------------------------
  64. // Modify this depending on your server's configurations.
  65. // If event_type is set to label mode, be sure to modify the code below.
  66.  
  67. - script PCLoginEvent -1,{
  68. set $@dbe_cnt,;
  69. while(callfunc("func_addentry", getd($@rid_database_name$ + $@dbe_cnt), playerattached()) != 0)
  70. set $@dbe_cnt, $@dbe_cnt + 1;
  71. set soundall_database, $@dbe_cnt;
  72. end;
  73. }
  74.  
  75. - script PCLogoutEvent -1,{
  76. callfunc "func_removeentry", getd($@rid_database_name$ + soundall_database), playerattached();
  77. end;
  78. }
  79.  
  80. // -------------------------- Sample Script -----------------------------------------
  81. // To use this library, call the function func_soundall
  82. // Syntax:
  83. // callfunc "func_soundall", <rid-array-variable>, <wav-file>;
  84.  
  85. prontera.gat,180,200,4 Sampler 111,{
  86. callfunc "func_soundall", $@rid_database_name$, "se_organ02";
  87. end;
  88. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Feb 27th, 2006
0

Re: Script problem help

there is no such thing (keywords) as function script in either c or c++. maybe in managed c++ (I don't know managed c++), but VC++ 6.0 compiler doesn't know how to compile managed code.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Feb 27th, 2006
0

Re: Script problem help

'Script' is an external function being called.
Its just general errors it contains, thats what I need help identifying..
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Feb 27th, 2006
0

Re: Script problem help

Quote originally posted by Mike182 ...
'Script' is an external function being called.
Its just general errors it contains, thats what I need help identifying..
not according to the code you posted -- its just so much garbage.

[edit]A closer look shows that the code you posted is neither C or C++, maybe pascal or some other language.
C++ Syntax (Toggle Plain Text)
  1. $@db_count

The above is not a C or C++ variable construction.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Feb 27th, 2006
0

Re: Script problem help

It is for a group of source files which is why some things dont make sense.
The errors I'm getting are:

C++ Syntax (Toggle Plain Text)
  1. F:\Mike\eAAC Test Part I.cpp(4) : error C2146: syntax error : missing ';' before identifier 'script'
  2. F:\Mike\eAAC Test Part I.cpp(4) : error C2501: 'function' : missing storage-class or type specifiers
  3. F:\Mike\eAAC Test Part I.cpp(4) : fatal error C1004: unexpected end of file found

Just general errors it's found.
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Feb 27th, 2006
0

Re: Script problem help

Quote originally posted by Mike182 ...
It is for a group of source files which is why some things dont make sense.
The errors I'm getting are:

C++ Syntax (Toggle Plain Text)
  1. F:\Mike\eAAC Test Part I.cpp(4) : error C2146: syntax error : missing ';' before identifier 'script'
  2. F:\Mike\eAAC Test Part I.cpp(4) : error C2501: 'function' : missing storage-class or type specifiers
  3. F:\Mike\eAAC Test Part I.cpp(4) : fatal error C1004: unexpected end of file found

Just general errors it's found.
Yup ! just as I already told you, the compiler has no clude what function keyword is. It ain't c or c++.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Feb 27th, 2006
0

Re: Script problem help

The file is a game script from RagnarokOnline, its a database management library.
Things like OnInit are commands from the games source, would it recognise it if I defined it?

EDIT:
Adding :
C++ Syntax (Toggle Plain Text)
  1. #define function
  2. #define script
  3. #ifndef function
  4. #ifndef script

Removed 2 of the 3 errors, last error is:

C++ Syntax (Toggle Plain Text)
  1. Part I.cpp(95) : fatal error C1004: unexpected end of file found

How can I fix this?
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Feb 27th, 2006
0

Re: Script problem help

the source was not written in either c or c++, maybe in basic of java. you will have to do a complete rewrite (port) if you want to use a c or c++ compiler. And the answer to your question is No -- simply declaring the function will not fix the errors.

[edit]
>>How can I fix this?

put at the very top of the program
C++ Syntax (Toggle Plain Text)
  1. #include "stdafx.h"
  2. .. // rest of code here

or remove precompiled header requireents.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Feb 27th, 2006
0

Re: Script problem help

Including that stdafix.h didnt fix it.. How do I remove the precompiled header requirements?
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Feb 27th, 2006
0

Re: Script problem help

menu Project --> Settings, select the c++ tab, select Category of Precompiled Headers then select the radio button Not using precompiled headers
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Print Max Prime Number???
Next Thread in C++ Forum Timeline: assignment operator for a 3d array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC