Jump to content
  • 0

Unexpected type for argument error.


BigBurrito

Question


  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

Can anyone help me figure out why this is happening. I'm still learning how to manage these values. Thank you in advance.

 

prontera,150,150,1	script	Pronterian#1::Pront[1]	844,{


OnInit:
getmapxy("$mapPRT"+strnpcinfo(2)+"$", $xPRT["+strnpcinfo(2)+"], $yPRT["+strnpcinfo(2)+"], UNITTYPE_NPC, "strnpcinfo(3)");

end;
}


I get this on my console:

[Warning]: Unexpected type for argument 2. Expected number.
[Debug]: Data: string value="+strnpcinfo(2)+"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)
[Warning]: Unexpected type for argument 2. Expected number.
[Debug]: Data: string value="+strnpcinfo(2)+"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)
[Warning]: Unexpected type for argument 1. Expected variable, got C_STR.
[Debug]: Data: string value="$mapPRT1$"
[Debug]: Function: getmapxy
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)
[Warning]: script: buildin_getmapxy: mapname value is not a variable.
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)

 

help.png

Edited by BigBurrito
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

My bad, i missed an apostrophe XD

getmapxy(getd("$mapPRT"+strnpcinfo(2)+"$"), getd("$xPRT["+atoi(strnpcinfo(2))+"]"), getd("$yPRT["+atoi(strnpcinfo(2))+"]"), UNITTYPE_NPC, strnpcinfo(3));


Anyway we can help you better if you post the script or infos of what you really want to achieve.

Maybe this could help too

-	script	Pronterian	-1,{
	end;

OnInit:
	donpcevent "::OnSetPCoord";
	end;

OnSetPCoord:
	.@id = atoi(strnpcinfo(2));
	getmapxy(.@map$, .@x, .@y, UNITTYPE_NPC);
	setd "$@PrtMap"+.@id+"$", .@map$;
	setd "$@PrtX"+.@id+"", .@x;
	setd "$@PrtY"+.@id+"", .@y;
	end;
}
prontera,150,150,1	duplicate(Pronterian)	Pronterian#1	844
prontera,150,152,1	duplicate(Pronterian)	Pronterian#2	844
prontera,150,154,1	duplicate(Pronterian)	Pronterian#3	844

then fetch the variables with $@PrtMap1$ $@PrtX1 $@PrtY1 and so on..
PS: I haven't test the script myself /gawi

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  143
  • Reputation:   30
  • Joined:  12/23/11
  • Last Seen:  

You have a few hidden symbols at first strnpcinfo(2) before and after 'o'

Just retype this part

Edited by Jarek
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

getmapxy(@mapname, @mapx, @mapy, UNITTYPE_NPC, "strnpcinfo(3)");

No need to make it hard :))

Edited by crazyarashi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

@Jarek what do you mean? Can you point it out if you wouldn’t mind please. Thanks :D

 

@crazyarashi that wouldn’t work for me.. since I’ll be duplicating the npc many times, and will be used in different locations, i dont want to set up one by one changing the numbers since i use these values couple of times in the middle of the script. Would be easier for me to just change the hidden npc name part and just change it to 1,2,3,4,5.... 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

You need to use getd to fetch the reference of the variable. and since strnpcinfo(2) returns a string, you need to convert it to number using atoi command.

Try

getmapxy(getd("$mapPRT"+strnpcinfo(2)+"$"), getd($xPRT["+atoi(strnpcinfo(2))+"]), getd($yPRT["+atoi(strnpcinfo(2))+"]), UNITTYPE_NPC, strnpcinfo(3));

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

@Technoken interesting. I will try once i get home. I wonder if instead of #number i use letters. Like Pronterian#A , Pronterian#B, etc? Would i need to convert too? Thanks for your response.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

[Warning]: Unexpected type for argument 2. Expected number.
[Debug]: Data: string value="+atoi(strnpcinfo(2))+"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)


[Warning]: Unexpected type for argument 1. Expected string.
[Debug]: Data: variable name='$xPRT' index=0
[Debug]: Function: getd
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)


[Warning]: Unexpected type for argument 2. Expected number.
[Debug]: Data: string value="+atoi(strnpcinfo(2))+"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)


[Warning]: Unexpected type for argument 1. Expected string.
[Debug]: Data: variable name='$yPRT' index=0
[Debug]: Function: getd
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)


[Error]: buildin_getmapxy: fatal error ! player not attached!
[Debug]: Function: getmapxy (5 parameters):
[Debug]: Data: reference name='$mapPRT1$' type=C_NAME
[Debug]: Please report this!!! - script->str_data.type=C_NOP
[Debug]: Data: variable name='0' index=0
[Debug]: Data: variable name='0' index=0
[Debug]: Data: number value=1
[Debug]: Data: string value="Pront[1]"
[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)


[Error]: buildin_getmapxy: variable '0' for mapX is not a server variable, but no player is attached!

[Debug]: Source (NPC): Pronterian#1 at prontera (150,150)

Got this error now.

I think I'm gonna have to do it manually.. ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

I think I've found a workaround. Can anyone confirm if this would not interfere with each other?

PD: Also, I've noticed the use of prefix . (dot) However I might need to call for other npcs X and Y pos, that is why I'm doing it still with [.npcNum]

 

///////////NPC1

prontera,150,150,1	script	Pronterian#1::Pront[1]	844,{


OnInit:
set .npcNum, atoi(strnpcinfo(2));
getmapxy(.PronterianMap$, .xPRT[.npcNum], .yPRT[.npcNum], UNITTYPE_NPC, "strnpcinfo(3)");

end;
}

///////////NPC2
prontera,150,152,1	script	Pronterian#2::Pront[2]	844,{


OnInit:
set .npcNum, atoi(strnpcinfo(2));
getmapxy(.PronterianMap$, .xPRT[.npcNum], .yPRT[.npcNum], UNITTYPE_NPC, "strnpcinfo(3)");

end;
}


///////////NPC3
prontera,150,154,1	script	Pronterian#3::Pront[3]	844,{


OnInit:
set .npcNum, atoi(strnpcinfo(2));
getmapxy(.PronterianMap$, .xPRT[.npcNum], .yPRT[.npcNum], UNITTYPE_NPC, "strnpcinfo(3)");

end;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.02
  • Content Count:  114
  • Reputation:   5
  • Joined:  07/16/16
  • Last Seen:  

@Technoken Thanks man. Worked. 

I tried your second suggestion. Doing duplicates, but for some reason, the .@id only sets to one number for all NPCs. I check this by using mes "+.@id+"; and they all showed the same number even tho on the NPC name I assigned them different numbers. Maybe a bug? I dont really know why it happens. 

Link to comment
Share on other sites

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.

×
×
  • Create New...