Jump to content
  • 0

Script to check items and auto kick if item not present


firefox26

Question


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  04/13/12
  • Last Seen:  

Im requesting for a script that checks an item on a certain map every 10 minutes and automatically kicks the player as soon as the item is not present.


the item im referring allows a player to warp on a map that has a warp restriction. the item is also a rental item for 2 hrs. thank you <3

Link to comment
Share on other sites

23 answers to this question

Recommended Posts

  • 2

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

11 hours ago, firefox26 said:

Im requesting for a script that checks an item on a certain map every 10 minutes and automatically kicks the player as soon as the item is not present.


the item im referring allows a player to warp on a map that has a warp restriction. the item is also a rental item for 2 hrs. thank you <3

In the unequip_script of your rental item add.

if( strcharinfo(3) == "geffen" && !( countitem(501) -1 ) ) warp "prontera",156,191;

And of course replace geffen with your map and 501 with your rental itemid.

  • Upvote 1
Link to comment
Share on other sites

  • 1

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

24 minutes ago, Erio-chan said:

@Cyro also Not working...

it does not check item and kick me out of the map when  consume potion/501.

It should be in the unequip database section. When the RENTAL ITEM RUNS-OUT it activates the unequip-script this is something I tested and it was working at that time. If something changed with the source between when I tested it there isn't anything I can do about that. I recommend testing it further and submitting a bug report.

  • Upvote 1
Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  88
  • Reputation:   10
  • Joined:  01/15/16
  • Last Seen:  

Hi! 
Reading the docs is always a good practice and you might find your answer much faster.
You can find them in your server folder under the doc folder, the one that interest you is the item_db.txt
There is an example of how an item is made and all of his parameters, you will see at the end this lines:

	Script: <"
		Script
		(it can be multi-line)
	">
	OnEquipScript: <" OnEquip Script (can also be multi-line) ">
	OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">

and the one that you want is this: 

OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">

so, in your db/re/item_db.txt in the item you are using just change the script line to the OnUnequipScript one (if its not there, just add it) 

Edited by Enthr
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  04/13/12
  • Last Seen:  

Sir @Skorm the item is a consumable item. would it still work?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

2 hours ago, firefox26 said:

Sir @Skorm the item is a consumable item. would it still work?

Yes

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

On 3/9/2017 at 4:28 AM, Skorm said:

In the unequip_script of your rental item add.


if( strcharinfo(3) == "geffen" && !( countitem(501) -1 ) ) warp "prontera",156,191;

And of course replace geffen with your map and 501 with your rental itemid.

NOT WORKING

Untitled.png

Untitled1.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  1137
  • Reputation:   290
  • Joined:  04/29/13
  • Last Seen:  

Use it as a NPC script instead db script

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

12 minutes ago, Cyro said:

Use it as a NPC script instead db script

Still not working...

//=================================================================//
//================= Custom leveling warper level 1 - 10 only ======//
//=================================================================//


prontera,150,177,6	script	Warper 1-10	858,{

	if (BaseLevel > 10) {
		mes "[ ^0065DFWarper^000000 ]";
		mes " These Area is not for you ";
		close;
	}
	if( strcharinfo(3) == "2@mir" && !( countitem(501) -1 ) ) 
	warp "prontera",156,191;
	
	mes "[ ^0065DFWarper^000000 ]";
	mes "Would you like to enter?";
	if (select("Yes!","No thanks.") == 2) close;
	warp "2@mir",101,95;
	close;
	
	OnInit:
		waitingroom "Leveling Area 1-10",0;
		end;
	}	
	
	

 

Untitled.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  1137
  • Reputation:   290
  • Joined:  04/29/13
  • Last Seen:  

-	script	Warper 	858,{
	if( strcharinfo(3) == "2@mir" && !( countitem(501) -1 ) ) 
	warp "prontera",156,191;
	close;
	}	

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

5 hours ago, Cyro said:

-	script	Warper 	858,{
	if( strcharinfo(3) == "2@mir" && !( countitem(501) -1 ) ) 
	warp "prontera",156,191;
	close;
	}	

 

@Cyro also Not working...

it does not check item and kick me out of the map when  consume potion/501.

Untitled.png

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:  

-	script	ItemCheck 	-1,{
OnPCLoadMapEvent:
	getmapxy(.@map$,.@mapx,.@mapy,0);
		if(.@map$!="2@mir") end;
			if(countitem(501) > 0){
			warp "prontera",156,191;
			end;
			}
		}

2@mir	mapflag	loadevent

For MapCheck.

 

//=================================================================//
//================= Custom leveling warper level 1 - 10 only ======//
//=================================================================//


prontera,150,177,6	script	Warper 1-10	858,{

	if (BaseLevel > 10) {
		mes "[ ^0065DFWarper^000000 ]";
		mes " These Area is not for you ";
		close;
		}
			if(countitem(501) > 0){
			mes "[ ^0065DFWarper^000000 ]";
			mes "This Item is not allowed inside";
			close;
	} else {	
			mes "[ ^0065DFWarper^000000 ]";
			mes "Would you like to enter?";
			if (select("Yes!","No thanks.") == 2) close;
			warp "2@mir",101,95;
			close;
	
			OnInit:
			waitingroom "Leveling Area 1-10",0;
			end;
			}	

For NPC

 

53 minutes ago, Erio-chan said:

@Cyro also Not working...

it does not check item and kick me out of the map when  consume potion/501.

Untitled.png


 

Edited by crazyarashi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

@crazyarashi it works but your script is for BAN item in map right? but I want is a key (rental) and when it expire inside the map then auto kick.

@Skorm I got you point, I will try it

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:  

1 hour ago, Erio-chan said:

@crazyarashi it works but your script is for BAN item in map right? but I want is a key (rental) and when it expire inside the map then auto kick.

@Skorm I got you point, I will try it

Spoiler

-    script    Weird    -1,{
set .@key, countitem(501);

OnInit:
    set .CheckON,0;
    
OnMinute00:
OnMinute01:
OnMinute02:
OnMinute03:
OnMinute04:
OnMinute05:
OnMinute06:
OnMinute07:
OnMinute08:
OnMinute09:
OnMinute10:
OnMinute11:
OnMinute12:
OnMinute13:
OnMinute14:
OnMinute15:
OnMinute16:
OnMinute17:
OnMinute18:
OnMinute19:
OnMinute20:
OnMinute21:
OnMinute22:
OnMinute23:
OnMinute24:
OnMinute25:
OnMinute26:
OnMinute27:
OnMinute28:
OnMinute29:
OnMinute30:
OnMinute31:
OnMinute32:
OnMinute33:
OnMinute34:
OnMinute35:
OnMinute36:
OnMinute37:
OnMinute38:
OnMinute39:
OnMinute40:
OnMinute41:
OnMinute42:
OnMinute43:
OnMinute44:
OnMinute45:
OnMinute46:
OnMinute47:
OnMinute48:
OnMinute49:
OnMinute50:
OnMinute51:
OnMinute52:
OnMinute53:
OnMinute54:
OnMinute55:
OnMinute56:
OnMinute57:
OnMinute58:
OnMinute59:

    set .CheckON,1;
    setnpctimer 0;
    initnpctimer;
    end;

OnTimer10000:
    if(strcharinfo(3) == "2@mir" && if (.@key < 1)){
    mes "[System]";
    mes "Your Key Has Expired";
    sleep 2000;    
    warp "prontera",156,191;
    end;
    }
OnTimer20000:
    if(strcharinfo(3) == "2@mir" && if (.@key < 1)){
    mes "[System]";
    mes "Your Key Has Expired";
    sleep 2000;    
    warp "prontera",156,191;
    end;
    }
OnTimer30000:
    if(strcharinfo(3) == "2@mir" && if (.@key < 1)){
    mes "[System]";
    mes "Your Key Has Expired";
    sleep 2000;
    warp "prontera",156,191;
    end;
    }
OnTimer40000:
    if(strcharinfo(3) == "2@mir" && if (.@key < 1)){
    mes "[System]";
    mes "Your Key Has Expired";
    sleep 2000;    
    warp "prontera",156,191;
    end;
    }
OnTimer50000:
    if(strcharinfo(3) == "2@mir" && if (.@key < 1)){
    mes "[System]";
    mes "Your Key Has Expired";
    sleep 2000;
    warp "prontera",156,191;
    end;
    }
OnTimer55000:
    set .CheckON,0;
    setnpctimer 0; 
    stopnpctimer;
    end;
    } 


This just came up in my mind LMAO don't know if it works XD Weird

Edited by crazyarashi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

@Skorm Still not working

Untitled.png

Link to comment
Share on other sites

  • 0

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

 

5 hours ago, crazyarashi said:

This just came up in my mind LMAO don't know if it works XD Weird

lol ... hahahaha maybe you should just try while(1) { blablablablabla; sleep2 10000; }

 

@firefox26 you can try this.

-	script	sample	-1,{
	
	OnInit:
		.map$ = "prontera";
		.itemid = 512;
		.interval = 5;
		
		setmapflag .map$, mf_loadevent;
		end;
		
	OnPCLoadMapEvent:
		if (strcharinfo(3) == .map$) {
			if (!countitem(.itemid)) {
				mes "Your item "+getitemname(.itemid)+" is gone. Warping out.";
				sleep2 1000;
				warp "SavePoint",0,0;
			}
			else {
				addtimer (.interval * 1000), .npc_name$+"::OnPCLoadMapEvent";
			}
		}
		end;
}

I am not sure how exactly you want it to run .... basically my method are same with @crazyarashi post.

 

EDIT:

.... its @Erio-chan ... /swt' 

kindly open your own topic if the request are different from topic starter, dont hijack topic and request a script that run different from original topic.

 

Edited by Emistry
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  1137
  • Reputation:   290
  • Joined:  04/29/13
  • Last Seen:  

skorm mentioned you must use that script in your rental item (in you case your custom key) unequip script. not as npc script ,

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

@Emistry opppss sorry xD

Edited by Erio-chan
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

35 minutes ago, Cyro said:

skorm mentioned you must use that script in your rental item (in you case your custom key) unequip script. not as npc script ,

For the last time can I ask how? :)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   48
  • Joined:  07/23/13
  • Last Seen:  

31 minutes ago, Erio-chan said:

For the last time can I ask how? :)

Quote

izlude,150,150,0 script TimeoutTest 100,{
 rentitem 501,5;
 end;
 
OnInit:
 setitemscript 501,"{dispbottom \"Unequiped run\";}",2;
}

I just test the @Skorm method and it work properly. 

Edited by yuchinin
change to proper format
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   48
  • Joined:  07/23/13
  • Last Seen:  

Quote

izlude,150,150,0 script TimeoutTest 100,{
 rentitem 501,5;
 end;
 
OnInit:
 setitemscript 501,"{if(strcharinfo(3)==\"izlude\") warp \"SavePoint\",0,0;}",2;
}

With condition, it work properly too.

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1678
  • Reputation:   704
  • Joined:  12/21/14
  • Last Seen:  

try this


-	script	script_name	-1,{
OnTimer1000:
if( strcharinfo(3) == "map" && (countitem(501) < 1) )//put the map name and the item id
warp "prontera",100,100;
end;
}

 

Edited by sader1992
|| insted of &&
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

3 hours ago, Emistry said:

 

lol ... hahahaha maybe you should just try while(1) { blablablablabla; sleep2 10000; }

 

@firefox26 you can try this.


-	script	sample	-1,{
	
	OnInit:
		.map$ = "prontera";
		.itemid = 512;
		.interval = 5;
		
		setmapflag .map$, mf_loadevent;
		end;
		
	OnPCLoadMapEvent:
		if (strcharinfo(3) == .map$) {
			if (!countitem(.itemid)) {
				mes "Your item "+getitemname(.itemid)+" is gone. Warping out.";
				sleep 1000;
				warp "SavePoint",0,0;
			}
			else {
				addtimer (.interval * 1000), .npc_name$+"::OnPCLoadMapEvent";
			}
		}
		end;
}

I am not sure how exactly you want it to run .... basically my method are same with @crazyarashi post.

 

EDIT:

.... its @Erio-chan ... /swt' 

kindly open your own topic if the request are different from topic starter, dont hijack topic and request a script that run different from original topic.

 

@EmistryI have test your script for @firefox26 and I got stuck on the message "Warping out".

		.map$ = "2@mir";
		.itemid = 7493;

I just edit these 2 line.

//sleep 1000;

when I disable sleep it warps me out but only when I use fly wing or before I go to map(when map load) and not when my custom Item(7493) expired.

Untitled.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   10
  • Joined:  07/23/16
  • Last Seen:  

Thanks for all the help whether its not my post xD

7493,Bloody_Temple_key,Bloody Temple key,3,0,,0,,,,,,,,,,,,,{},{},{if( strcharinfo(3) == "2@mir" && !( countitem(7493) -1 ) ) warp "prontera",157,177;}

This works for me.

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...