Jump to content
  • 0

[Error] : script:op_2: invalid data for operator C_NE (Cashpoint on kill script)


Question

Posted (edited)

Hello, I am trying to make a script that will reward players with cashpoints whenever they kill a boss/miniboss/mvp/champion mob. I have had some success with help from the discord, but Im not quite there yet, and am receiving an error. Been beating my head against the wall trying to fix things, so I figured I would come here and ask if anyone has any idea how to fix this and get it to do what I want it to.

 

The script in question (Original):

Spoiler
  -	script	cashpoints	-1,{
	OnInit:
		setarray .champions$,"Elusive","Furious","Ringleader","Solid","Swift";
		end;
	OnNPCKillEvent:
		if (  getunitdata(killedgid, .@data) != -1  ){
			.@mode = .@data[UMOB_MODE];
            if(.@mode & MD_MVP){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 5, 10 );
				else 
					#CASHPOINTS += rand( 10, 15 );    //MVP
			}else if(.@mode & MD_STATUSIMMUNE){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 3, 8 );
				else 
					#CASHPOINTS += rand( 8, 13 );    //miniboss
				}else {
					for(.@i = 0; .@i < getarraysize(.champions$); .@i++){
						if(compare(.@mobname$,.champions$[.@i])){
							if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
								#CASHPOINTS += rand( 1, 3 );
							else 
								#CASHPOINTS += rand( 3, 6 );    //cashpoints
							break;
						}
					} //Champion tests
				}
		}
		end;
}

 

And the error I am receiving whenever I kill any mob at all:

[Error] : script:op_2: invalid data for operator C_NE
[Debug] : Data: C_ARG
[Debug] : Data: number value=-1

 Thanks in advance for any and all help!

 

Completed and functional script:

Spoiler
-	script	cashpoints	-1,{
	OnInit:
		setarray .champions$,"Elusive","Furious","Ringleader","Solid","Swift";
		end;
	OnNPCKillEvent:
		.@mobname$ = getmonsterinfo(killedrid,MOB_NAME)
		.@exists = getunitdata(killedgid, .@data);
		if ( .@exists != -1  ){
			
			.@mode = .@data[UMOB_MODE];
            if(.@mode & MD_MVP){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 5, 10 );
				else 
					#CASHPOINTS += rand( 10, 15 );    //MVP
			}

			else if(.@mode & MD_STATUSIMMUNE){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 3, 8 );
				else 
					#CASHPOINTS += rand( 8, 13 );    //miniboss
			}else {
				for(.@i = 0; .@i < getarraysize(.champions$); .@i++){
					if(compare(.@mobname$,.champions$[.@i])){
						if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
							#CASHPOINTS += rand( 1, 3 );
						else 
							#CASHPOINTS += rand( 3, 6 );    //cashpoints
						break;
					}
				} //Champion tests
			}
		}
		end;
}

 

 

Edited by Necrosx

2 answers to this question

Recommended Posts

  • 1
Posted

Hello. Using getunitdata inside a if statement is causing the error. Don't know why.
Try:

-	script	cashpoints	-1,{
	OnInit:
		setarray .champions$,"Elusive","Furious","Ringleader","Solid","Swift";
		end;
	OnNPCKillEvent:
		
		.@exists = getunitdata(killedgid, .@data);
		if ( .@exists != -1  ){
			
			.@mode = .@data[UMOB_MODE];
            if(.@mode & MD_MVP){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 5, 10 );
				else 
					#CASHPOINTS += rand( 10, 15 );    //MVP
			}

			else if(.@mode & MD_STATUSIMMUNE){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 3, 8 );
				else 
					#CASHPOINTS += rand( 8, 13 );    //miniboss
				}else {
					for(.@i = 0; .@i < getarraysize(.champions$); .@i++){
						if(compare(.@mobname$,.champions$[.@i])){
							if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
								#CASHPOINTS += rand( 1, 3 );
							else 
								#CASHPOINTS += rand( 3, 6 );    //cashpoints
							break;
						}
					} //Champion tests
				}
		}
		end;
}

 

  • Upvote 1
  • 0
Posted (edited)
16 hours ago, Racaae said:

Hello. Using getunitdata inside a if statement is causing the error. Don't know why.
Try:

-	script	cashpoints	-1,{
	OnInit:
		setarray .champions$,"Elusive","Furious","Ringleader","Solid","Swift";
		end;
	OnNPCKillEvent:
		
		.@exists = getunitdata(killedgid, .@data);
		if ( .@exists != -1  ){
			
			.@mode = .@data[UMOB_MODE];
            if(.@mode & MD_MVP){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 5, 10 );
				else 
					#CASHPOINTS += rand( 10, 15 );    //MVP
			}

			else if(.@mode & MD_STATUSIMMUNE){
				if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
					#CASHPOINTS += rand( 3, 8 );
				else 
					#CASHPOINTS += rand( 8, 13 );    //miniboss
				}else {
					for(.@i = 0; .@i < getarraysize(.champions$); .@i++){
						if(compare(.@mobname$,.champions$[.@i])){
							if ( getmonsterinfo( killedrid, MOB_LV ) < 71 ) 
								#CASHPOINTS += rand( 1, 3 );
							else 
								#CASHPOINTS += rand( 3, 6 );    //cashpoints
							break;
						}
					} //Champion tests
				}
		}
		end;
}

 

Progress! It works for minibosses and MVP's now, but not for champions, but no errors...

Edit- Solved. Completed script is in the original post.

Edited by Necrosx

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...