Jump to content
  • 0

help please


blakbord

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

I want to use this script in an item for example..
670,Gold_Coin_Moneybag,Bag of Gold Coins,0,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{},{},{}
thanks..

-    script    vip_for_1week    -1,{
OnPCLoginEvent:
    if (getgroupid() != 0) end;
    
    // first time logging into this account
    if (#VIP_expire == 0) {
        set #VIP_expire, gettimetick(2) + (7*86400); // 7 days
        dispbottom "Welcome to the server!";
        dispbottom "You have been upgraded to a VIP for 1 week.";
    }
    
    if (#VIP_expire > gettimetick(2)) {
        // they still have time left
        dispbottom "VIP Rental : expires in " + callfunc("Time2Str",#VIP_expire);
        atcommand "@adjgroup 1";
        deltimer strnpcinfo(3)+"::OnPCLoginEvent";
        if ((#VIP_expire - gettimetick(2)) < 2147483) { // prevent overflow error
            addtimer (#VIP_expire - gettimetick(2)) *1000, strnpcinfo(3)+"::OnPCLoginEvent";
        } else {
            addtimer 2147483000, strnpcinfo(3)+"::OnPCLoginEvent";
        }
    } else if (#VIP_expire > 1) {
        set #VIP_expire, 1;
        atcommand "@adjgroup 0";
        dispbottom "Your VIP Rental has expired.";
    }
    end;
}
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Yeap buddy but that's what the first script you posted is intended to do. The function that we have just created will call the NPC that already have this feature. As I said before, you need to check the script validations because that might be your problem.
 
However, if you just want to add 7 days without checking if players already have received it or not, just put this on your item script and forget all I said before.
670,Gold_Coin_Moneybag,Bag of Gold Coins,2,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{ set #VIP_expire, gettimetick(2) + (7*86400); },{},{}

C ya!

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Hello blackbord, how are you?

You can use the doevent command on the first {} found in the item script.  Something like this:
 

670,Gold_Coin_Moneybag,Bag of Gold Coins,2,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{ doevent "vip_for_1week::OnPCLoginEvent"; },{},{}

I also have changed the item type from 0 to 2 (Healing -> Usable).

Another solution is to change this script to be a function, so you'll be able to use whenever you needed it.

I hope it works, good luck.

Edited by _Okuz_
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

Hello blackbord, how are you?

You can use the doevent command on the first {} found in the item script.  Something like this:

 

670,Gold_Coin_Moneybag,Bag of Gold Coins,2,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{ doevent "vip_for_1week::OnPCLoginEvent"; },{},{}

I also have changed the item type from 0 to 2 (Healing -> Usable).

Another solution is to change this script to be a function, so you'll be able to use whenever you needed it.

I hope it works, good luck.

thanks for the response..

the doevent is not working.. so i tried the function thing..

 

is it like this? I'm not really good in scripting..

function    script    vip_for_1week    ,{
OnPCLoginEvent:
    if (getgroupid() != 0) end;
    
    // first time logging into this account
    if (#VIP_expire == 0) {
        set #VIP_expire, gettimetick(2) + (7*86400); // 7 days
        dispbottom "Welcome to the server!";
        dispbottom "You have been upgraded to a VIP for 1 week.";
    }
    
    if (#VIP_expire > gettimetick(2)) {
        // they still have time left
        dispbottom "VIP Rental : expires in " + callfunc("Time2Str",#VIP_expire);
        atcommand "@adjgroup 1";
        deltimer strnpcinfo(3)+"::OnPCLoginEvent";
        if ((#VIP_expire - gettimetick(2)) < 2147483) { // prevent overflow error
            addtimer (#VIP_expire - gettimetick(2)) *1000, strnpcinfo(3)+"::OnPCLoginEvent";
        } else {
            addtimer 2147483000, strnpcinfo(3)+"::OnPCLoginEvent";
        }
    } else if (#VIP_expire > 1) {
        set #VIP_expire, 1;
        atcommand "@adjgroup 0";
        dispbottom "Your VIP Rental has expired.";
    }
    end;
}

the item is like this?

670,Gold_Coin_Moneybag,Bag of Gold Coins,2,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "vip_for_1week"; },{},{}
Edited by blakbord
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Hmm... Did you get any output of the map-server console when you tried the donpcevent?
 

I noticed that you left a comma before the first { in your function, please remove it. And you still need a NPC to count the timer, so, you can't just turn that NPC into a function because functions cannot have timers, you need to write some code in order to adjust the things.
 

Change your callfunc to callfunc("F_vip_for_1week"); and replace your current code with the bellow code, I put 2 debugs on it to check if the function is being accessed or not and if the NPC event is being accessed or not, let me know the map-server console outputs.

-	script	vip_for_1week	-1,{
OnPCLoginEvent:
	debugmes "Event found!";

	if (getgroupid() != 0) end;
	
	// first time logging into this account
	if (#VIP_expire == 0) {
		set #VIP_expire, gettimetick(2) + (7*86400); // 7 days
		dispbottom "Welcome to the server!";
		dispbottom "You have been upgraded to a VIP for 1 week.";
	}
	
	if (#VIP_expire > gettimetick(2)) {
		// they still have time left
		dispbottom "VIP Rental : expires in " + callfunc("Time2Str",#VIP_expire);
		atcommand "@adjgroup 1";
		deltimer strnpcinfo(3)+"::OnPCLoginEvent";
		if ((#VIP_expire - gettimetick(2)) < 2147483) { // prevent overflow error
			addtimer (#VIP_expire - gettimetick(2)) *1000, strnpcinfo(3)+"::OnPCLoginEvent";
		} else {
			addtimer 2147483000, strnpcinfo(3)+"::OnPCLoginEvent";
		}
	} else if (#VIP_expire > 1) {
		set #VIP_expire, 1;
		atcommand "@adjgroup 0";
		dispbottom "Your VIP Rental has expired.";
	}
	end;
}

function	script	F_vip_for_1week	{
	debugmes "Function found!";
	doevent "vip_for_1week::OnPCLoginEvent";
}

Can you explain what intended to do when a player uses a coin? What they are going to receive? I'm telling you this because maybe there's a better solution for this.

C ya!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

it's checking the NPC and the function..
123123_zpsdeyvnrw2.jpg

and for the item, based on the NPC Script.. upon logging in the game you'll get a VIP good for 1 week..
this is the scenario I want..

ex. item = bag of coins
 

when bag of coins is used it will display this

dispbottom "You have been upgraded to a VIP for 1 week.";

and in every 1hour or whenever you're logging in the game it will display this
dispbottom "VIP : expires in " + callfunc("Time2Str",#VIP_expire);
to check your VIP how much time is left..
 
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

Ok, here's what I got from the map-server console:

 

The first debug printed is regarding your Login. The second is regarding the function that was invoked by using the item and the third is regarding the login event that was triggered by our function. So, there's nothing wrong with our script or logic!

 

Try to use another account because as you can see in the script, if you are already a VIP or if you are a GM (getgroupid != 0) you won't be able to proceed and the results will be different from what you expect.

 

C ya!

Edited by _Okuz_
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

I think I've found what I've been looking for.. but too bad the link is broken..

https://rathena.org/board/topic/79261-vip-system/?p=182888
Edited by blakbord
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

 

Yeap buddy but that's what the first script you posted is intended to do. The function that we have just created will call the NPC that already have this feature. As I said before, you need to check the script validations because that might be your problem.
 
However, if you just want to add 7 days without checking if players already have received it or not, just put this on your item script and forget all I said before.
670,Gold_Coin_Moneybag,Bag of Gold Coins,2,100000,,400,,,,,0xFFFFFFFF,7,2,,,,,,{ set #VIP_expire, gettimetick(2) + (7*86400); },{},{}

C ya!

 

thanks for responding for my help @_Okuz_ you really help a lot..

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