Jump to content
  • 0

PvP Bet Duel Attachrid Error.......


caspa

Question


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  


prontera,205,156,5 script Duel Gambling 953,{
set @npcname$,"[Duel Manager]";
L_mm:
mes @npcname$;
//If already a duel is going on
if(.gambling) {
mes "A duel is starting, please wait until the duel is over";
close;
}

mes callfunc("F_Hi") + " " + strcharinfo(0);
//If the challenger and the one accepting the duel have registred and the duel is ready to start
if(.char$ == strcharinfo(0) && .char2$ != "") {
mes "^0000FF" +.char2$+ "^000000 is waiting for you to start the duel!";
if(.zeny) mes "Dueling for total ^FF0000" +.zeny+ "^000000 zeny.";
if(.item) mes "The player duel for a ^FF0000" + callfunc("F_getitemname2",.item2[0],.item2[1],.item2[2],.item2[3],.item2[4],.item2[5]) + "^000000";
mes "What would you like to have?";
next;
menu "Start Duel",L_sduel,"Cancel Duel",L_cduel;
}
//If the one accept the duel is going to talk to the npc
if(.waiting) {
mes "The duel gonna start soon!";
close;
}
//If the challenger has registred, speaks again to the npc and no one accepted it
if(.char$ == strcharinfo(0)) {
mes "Please wait for your challenger.";
next;
menu "Cancel Duel",L_cduel,"I will wait",-;
close;
}
//If a challenger has registred, another person speaks to the npc and no one has accepted before
if(.char$ != "") {
mes "There is a player is waiting for gambling";
mes "What would you like to have?";
next;
menu "Player and Gamble Information",-,"Send Duel invitation to the player",L_iduel,"Duel Gambling?",L_info;
mes @npcname$;
mes "The player that challange is named ^0000FF"+.char$+"^000000";
if(.zeny) mes "The player duel for ^FF0000" +.zeny+ "^000000 zeny.";
if(.item) mes "The player duel for a ^FF0000" + callfunc("F_getitemname2",.item[0],.item[1],.item[2],.item[3],.item[4],.item[5]) + "^000000";
next;
goto L_mm;
}
//If no challenger is registred.
else {
mes "No player waiting for gambling currently";
mes "What would you like to do?";
next;
menu "Start a duel",-,"Duel Gambling?",L_info;
set .zeny,callfunc("F_PDZeny",0);
Initnpctimer;
set .char$,strcharinfo(0);
mes @npcname$;
mes "Please wait for your oppenent.";
announce .char$+ " is waiting for a duel!",bc_map|bc_blue;
close;
}

//This party will run after someone accepted the challenge of a challenger
L_iduel:
set .zeny,callfunc("F_PDZeny",.zeny);
set .char2$,strcharinfo(0);
set .waiting,1;
mes @npcname$;
mes "Please wait while i inform your oppenent.";
announce .char$+ ", you have a challenger!",bc_map|bc_blue;
close;

//After both players registred and the challenger starts the duel.
L_sduel:
mes @npcname$;
mes "We will start the duel immediately.";
close2;
attachrid getcharid(3,.char2$);
warp "pvp_n_1-1",90,50;
attachrid getcharid(3,.char$);
set dueling,1;
warp "pvp_n_1-1",110,50;
atcommand "@duel " + .char2$;
attachrid getcharid(3,.char2$);
atcommand "@accept";
set dueling,1;
// detachrid;
set .gambling,1;
announce .char$+ " has start a duel with " +.char2$+ "!",bc_map|bc_blue;
end;

//If only the challenger is registred and cancels or if both registred and the challenger cancels the duel.
L_cduel:
announce "The duel was canceld by " +.char$,bc_map|bc_blue;
mes @npcname$;
mes "Very well, " + callfunc("F_Bye");
set dueling,0;
set Zeny,Zeny+(.zeny/2);
close2;
if((.char2$ != "") && (attachrid (getcharid(3,.char2$)))) {
attachrid getcharid(3,.char2$);
set Zeny,Zeny+(.zeny/2);
set dueling,0;
// detachrid;
}
set .char$,"";
set .char2$,"";
set .gambling,0;
set .waiting,0;
set .zeny,0;
end;

//If you click on information for the duel.
L_info:
mes @npcname$;
mes "I will allow 2 player to duel each other,";
mes "players have to duel with gambling,";
next;
mes @npcname$;
mes "Gambling inlcude item and zeny";
mes "Only one type was able to gamble with.";
mes "If gambling zeny, the gamble zeny amount must be same amount as oppenent gamble.";
next;
mes @npcname$;
mes "Maximum time for waiting duel and dueling is 5 minute.";
next;
goto L_mm;

//If 5 Minutes passed after the challenger registred and no one accepts it.
OnTimer300000:
announce "No challenger or the time is over, the duel was cancel.",bc_map|bc_blue;
if((.char$ != "") && (attachrid (getcharid(3,.char$)))) {
set Zeny,Zeny+(.zeny/2);
set dueling,0;
}
if((.char2$ != "") && (attachrid (getcharid(3,.char2$)))) {
set Zeny,Zeny+(.zeny/2);
set dueling,0;
}
// detachrid;
set .char$,"";
set .char2$,"";
set .gambling,0;
set .waiting,0;
set .zeny,0;
stopnpctimer;
end;

//When a player kills his oppenent.
OnPCKillEvent:
if(!dueling) end;
set Zeny,Zeny+.zeny;
atcommand "@leave";
announce strcharinfo(0)+" has win the duel!",bc_map|bc_blue;
set dueling,0;
attachrid killedrid;
set dueling,0;
// detachrid;
set .char$,"";
set .char2$,"";
set .gambling,0;
set .waiting,0;
set .zeny,0;
set .waiting,0;
end;

//When a player dies.. (Just incase he doesnt get killed by his oppenent)
OnPCDieEvent:
if(!dueling) end;
if (killerrid == 0)
{
announce "The duel has been canceld because "+strcharinfo(0)+" died", bc_map|bc_blue;
if (strcharinfo(0) == .char$)
{
attachrid getcharid(3,.char2$);
set Zeny,Zeny+.zeny/2;
}
if (strcharinfo(0) == .char2$)
{
attachrid getcharid(3,.char$);
set Zeny,Zeny+.zeny/2;
}
atcommand "@leave";
set dueling,0;
// detachrid;
set .char$,"";
set .char2$,"";
set .gambling,0;
set .waiting,0;
set .zeny,0;
set .waiting,0;
end;
}
}
//Function for gambling for Zeny
Function script F_PDZeny {
If(!getarg(0)) {
mes @npcname$;
mes "How many zeny you would like to duel with?";
next;
input .@zeny;
If(.@zeny > Zeny || !.@zeny) {
mes "You don' have enough zeny to duel! I won't allow that!";
close;
}
set Zeny,Zeny-.@zeny;
return .@zeny;
}
If(getarg(0) > Zeny) {
mes "You don't have enough zeny to duel! I won't allow that!";
close;
}
else
set Zeny,Zeny-getarg(0);
set .@zeny,getarg(0)*2;
return .@zeny;
}

Can somebody help me and check the script..... or give me a much less bug script please..............

post-3034-0-54637500-1359190576_thumb.jpg

Edited by caspa
Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  110
  • Reputation:   1
  • Joined:  04/03/12
  • Last Seen:  

+1 to this...........

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

Is there a chance that this topic will be solved?............. every hour i check the forum hoping it would get answered but i'm not getting any luck.......

all i need is a simple checking of the script.... hence im noob on scripting.............

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@caspa

i dont think you uploaded the correct script...

i cant find any line that is related to your problems that you shown in the mapserver....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

i've uploaded the correct files....... and i have a very good feeling that the error comes from here.......



//----------If 5 Minutes passed after the challenger registred and no one accepts it.
OnTimer300000:
announce "The duel has been canceled, because there was no challenger...",bc_map|bc_blue;
if((.char$ != "") && (attachrid (getcharid(3,.char$)))) {
set Zeny,Zeny+(.zeny);
set dueling,0;
}
if((.char2$ != "") && (attachrid (getcharid(3,.char2$)))) {
set Zeny,Zeny+(.zeny);
set dueling,0;
}
// detachrid;
set .char$,"";
set .char2$,"";
set .gambling,0;
set .waiting,0;
set .zeny,0;
stopnpctimer;
end;

BUMP BUMP BUMP...............

Edited by caspa
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

BUMP.....................

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Your error is 'coz of that.

//If 5 Minutes passed after the challenger registred and no one accepts it.
OnTimer300000:
announce "No challenger or the time is over, the duel was cancel.",bc_map|bc_blue;

A player must be attached to the NPC using bc_map.

- bc_map: Message is sent to everyone in the same map as the source of the broadcast (see below).

Here a little revision.

// Comment if you already have this function
function    script    int__    {
   set .@num, getarg(0);
   set .@numString$, getarg(0);
   if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
   set .@l, getstrlen(.@numString$);
   for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
       set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
       if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
   }
   return .@num$;
}

prontera,205,156,5	script	Duel Gambling	953,{
set .@npcname$,"[ Duel Manager ]";
L_mm:
mes .@npcname$;

// If Duel cancel and player was not online.
//-----------------------------------------
if( dueling && .char$ != strcharinfo(0) && .char2$ != strcharinfo(0) ) {
	set Zeny, Zeny + dueling;
	dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
	set dueling, 0;
}

//If already a duel is going on
if( .gambling ) {
	mes "A duel is starting, please wait until the duel is over.";
	close;
}

mes callfunc("F_Hi") +" "+ strcharinfo(0) +".";
//If the challenger and the one accepting the duel have registred and the duel is ready to start
if( .char$ == strcharinfo(0) && .char2$ != "" ) {
	mes "^0000FF"+ .char2$ +"^000000 is waiting for you to start the duel!";
	if( .zeny )
		mes "Dueling for total ^FF0000"+ callfunc( "int__", .zeny ) +"^000000 zeny.";
	mes "What would you like to do ?";
	next;
	menu "~ ^777777Start Duel.^000000",L_sduel,"~ ^777777Cancel Duel.^000000",L_cduel;
}

//If the one accept the duel is going to talk to the npc
if( .waiting ) {
	mes "The duel gonna start soon !";
	close;
}

//If the challenger has registred, speaks again to the npc and no one accepted it
if( .char$ == strcharinfo(0) ) {
	mes "Please wait for your challenger.";
	next;
	menu "~ ^777777Cancel Duel.^000000",L_cduel,"~ ^777777I will wait.^000000",-;
	close;
}
//If a challenger has registred, another person speaks to the npc and no one has accepted before
if( .char$ != "" ) {
	mes "There is a player is waiting for gambling.";
	mes "What would you like to do ?";
	next;
	menu "~ ^777777Player and Gamble Information.^000000",-,"~ ^777777Send Duel invitation to the player.^000000",L_iduel,"~ ^777777Duel Gambling ?^000000",L_info;
	mes .@npcname$;
	mes "The player that challenge is named ^0000FF"+ .char$ +"^000000";
	if( .zeny )
		mes "The player duel for ^FF0000"+ callfunc( "int__", .zeny ) +"^000000 zeny.";
	next;
	goto L_mm;
}
//If no challenger is registred.
else {
	mes "No one is waiting for gamble currently.";
	mes "What would you like to do ?";
	next;

	menu "~ ^777777Start a duel.^000000",-,"~ ^777777Duel Gambling ?^000000",L_info;
	set .zeny, callsub( L_PDZeny, 0, .@npcname$ );
	initnpctimer;
	set .char$, strcharinfo(0);
	mes .@npcname$;
	mes "Please wait for your opponent.";
	announce "[ "+ .char$ +" ] bet "+ callfunc( "int__", dueling ) +" Zeny that no one could kill him ! He is waiting for an opponent !",bc_map|bc_blue;
	close;
}

//This party will run after someone accepted the challenge of a challenger
L_iduel:
if( .char2$ != "" || .char$ == "" ) {
	mes "Sorry you are too slow.";
	close;
}
set .zeny, callsub( L_PDZeny, .zeny, .@npcname$ );
set .char2$, strcharinfo(0);
set .waiting, 1;

mes .@npcname$;
mes "Please wait while I inform your opponent.";
announce "[ "+ .char$ +" ] your challenger is [ "+ .char2$ +" ] !",bc_map|bc_blue;
close;

//After both players registred and the challenger starts the duel.
L_sduel:
if( .char2$ == "" ) {
	mes "Sorry the duel is cancelled.";
	close;
}
mes .@npcname$;
mes "We will start the duel immediately.";
close2;

if( !isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
	dispbottom "Sorry, "+ .char2$ +" is not online.";
	end;
}
percentheal 100, 100;
attachrid( getcharid( 3,.char2$ ) );
warp "pvp_n_1-1",90,50;
percentheal 100, 100;

attachrid( getcharid( 3,.char$ ) );
warp "pvp_n_1-1",110,50;
atcommand "@duel "+ .char2$;

attachrid( getcharid( 3,.char2$ ) );
atcommand "@accept";
set .gambling, 1;
announce "[ "+ .char$ +" ] start a duel with [ "+ .char2$ +" ] !",bc_map|bc_blue;
end;

//If only the challenger is registred and cancels or if both registred and the challenger cancels the duel.
L_cduel:
if( .char$ != strcharinfo(0) ) {
	mes "Sorry the duel is already cancelled.";
	close;
}
announce "The duel was canceled by [ "+ .char$ +" ].",bc_map|bc_blue;
mes .@npcname$;
mes "Very well, "+ callfunc("F_Bye");
set Zeny, Zeny + dueling;
dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
set dueling, 0;
close2;
if( .char2$ != "" && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
	attachrid( getcharid( 3,.char2$ ) );
	set Zeny, Zeny + dueling;
	dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
	set dueling, 0;
}

L_resetvar:
set .char$, "";
set .char2$, "";
set .gambling, 0;
set .waiting, 0;
set .zeny, 0;
stopnpctimer;
end;

//If you click on information for the duel.
L_info:
mes .@npcname$;
mes "I will allow 2 players to duel each other,";
mes "players have to duel with gambling.";
next;
mes .@npcname$;
mes "The gamble zeny must be same amount as opponent gamble.";
next;
mes .@npcname$;
mes "Maximum time for waiting duel and dueling is 5 minutes.";
next;
goto L_mm;

//If 5 Minutes passed after the challenger registred and no one accepts it.
OnTimer300000:
announce "No challenger or the time is over, the duel was canceled.",bc_blue|bc_npc;
if( .char$ != "" && isloggedin( getcharid( 3,.char$ ),getcharid( 0,.char$ ) ) ) {
	attachrid( getcharid( 3,.char$ ) );
	set Zeny, Zeny + dueling;
	dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
	set dueling, 0;
}
if( .char2$ != "" && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
	attachrid( getcharid( 3,.char2$ ) );
	set Zeny, Zeny + dueling;
	dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
	set dueling, 0;
}
goto L_resetvar;

//When a player kills his opponent.
OnPCKillEvent:
if( !dueling || ( dueling && strcharinfo(0) != .char$ && strcharinfo(0) != .char2$ ) ) end;

set Zeny, Zeny + dueling * 2;
dispbottom "You win "+ callfunc( "int__", dueling * 2 ) +" Zeny !";
set dueling, 0;
atcommand "@leave";
announce "[ "+ strcharinfo(0)+ " ] win the duel!",bc_map|bc_blue;

attachrid killedrid;
set dueling, 0;
goto L_resetvar;


//When a player dies.. (Just incase he doesnt get killed by his oppenent)
OnPCDieEvent:
if( !dueling || ( dueling && strcharinfo(0) != .char$ && strcharinfo(0) != .char2$ ) ) end;
if( !killerrid ) {
	announce "The duel has been cancelled because "+ strcharinfo(0) +" died.", bc_map|bc_blue;
	set dueling, 0;
	atcommand "@leave";
	if( strcharinfo(0) == .char$ && isloggedin( getcharid( 3,.char2$ ),getcharid( 0,.char2$ ) ) ) {
		attachrid( getcharid( 3,.char2$ ) );
		set Zeny, Zeny + dueling;
		dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
		set dueling, 0;
	}
	else if( strcharinfo(0) == .char2$ && isloggedin( getcharid( 3,.char$ ),getcharid( 0,.char$ ) ) ) {
		attachrid( getcharid( 3,.char$ ) );
		set Zeny, Zeny + dueling;
		dispbottom "You collected you previous gamble : "+ callfunc( "int__", dueling ) +" Zeny.";
		set dueling, 0;
	}
	goto L_resetvar;
}
end;

// Label for gambling Zeny
// -----------------------------

L_PDZeny:
set .@npcname$, getarg(1);
if( !getarg(0) ) {
	mes .@npcname$;
	mes "How many zeny you would like to bet ?";
	next;
	if( input( .@zeny, 1, Zeny ) != 0 ) {
		mes .@npcname$;
		mes "You don't have enough zeny to duel! I won't allow that!";
		close;
	}
	if( .char$ != "" ) {
		mes .@npcname$;
		mes "Sorry you were too slow. Someone already bet.";
		close;
	}
	set Zeny, Zeny - .@zeny;
	set dueling, .@zeny;
}
else {
	if( getarg(0) > Zeny ) {
		mes .@npcname$;
		mes "You don't have enough zeny to duel! I won't allow that!";
		close;
	}
	else {
		if( .char2$ != "" || .char$ == "" ) {
			mes .@npcname$;
			mes "Sorry you were too slow."+ ( .char2$ != "" ? " Someone already bet." : "" );
			close;
		}
		set Zeny, Zeny - getarg(0);
		set dueling, getarg(0);
		set .@zeny, getarg(0) * 2;
	}
}
return .@zeny;
}

Edited by Capuche
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

Thank you [ Problem Solved ]

Edited by caspa
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...