Jump to content

Hyroshima

Members
  • Posts

    163
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by Hyroshima

  1. I did this example

    prontera,161,185,5	script	NPCTIMED	112,{
    
    	if(#TalkTimer > gettimetick(2))
    	{
    		mes "You have to wait!";
    		close;
    	}
    	else
    	{
    		for(set .@i,0; .@i<getarraysize($Talkip$); set .@i,.@i+1)
    		{ if($Talkip$[.@i] == getcharip()){ deletearray $Talkip$[.@i],1; set .@i,getarraysize($Talkip$); } }
    	}
    
    
    	mes "Hi...";
    	mes "save teste?";
    	if(select("Yes:Not")==2){ close; }
    	
    	mes "Ok, ready";
    	set #TalkTimer,gettimetick(2)+(60*60*5);
    	setarray $Talkip$[(getarraysize($Talkip$) ? getarraysize($Talkip$):0)],getcharip();
    	close;
    }

     

  2. 14 hours ago, Emistry said:

    #1

    
    OnSecXX:

    doesn't exist, but this is redundant and unnecessary because OnMinuteXX already can fulfill what you looking for.

     

    #2

    
    while(1) {
    	// process what you want
    	sleep 1000;
    }

    this attempt aren't actually recommended, people has been abusing how to use this trick for their convenience, without knowing the consequences.

    Whenever the script has done what its instructed to do, it should free up the resource, but this attempts doesn't free up the resource.

     

    #3

    
    OnMinuteXX:

    due to user required to duplicate from 00 ~ 59th minutes, its become redundant work, but its exactly what you need. Fyi, it free up the resource once it done its part.

     

    #4

    
    OnTimer60000:
    	// process whatever you want here.
    OnInit:
    	initnpctimer;
    	end;

    more elegant, and less redundant work, doesn't required user to duplicate all the OnMinuteXX like attempt #3 did, and yes it also free up the resources once it done its part.

     

    Conclusion: you should pick between attempt #3 and #4. Personally, I would prefer #4.

    Thanks for attention, but my idea is not to leave a time attachment, and work only when called similar to other labels that have a trigger that in this case it would always have been an increase in the minute real time.

    I will analyze and check how it would behave and try to create this function ^^.

     

    #Conclusion: you should pick between attempt #3 and #4. Personally, I would prefer #4.
      *this would also be the one I would use ^^

  3. I haven't tested it, but I hope it's the way you asked.


    you define the cooldown in:

    set .@cooldown,60; //time in minute

     

    the changes I made for you to understand
     

    ~1 before
    
    if ( strcharinfo(3) == strnpcinfo(4))
      .@online++;
    
    ~ afeter
      
    if ( strcharinfo(3) == strnpcinfo(4) && RoomCD < gettimetick(2)) .@online++; else set .@CDnicks$,.@CDnicks$+strcharinfo(0)+", ";
    
    
    ~2 before
    
    else if ( .party_id ) {
     mes "[MvP Ladder Warper]";
     mes "I'm sorry, but a party is currently playing the game. Please standby until the party is finished.";
     mes "Thank you.";
     close;
    }
    
    ~ afeter
    
    else if ( .@CDnicks$ != "" ) {
     mes "[MvP Ladder Warper]";
     mes "There are players in your group with active cooldown!";
     mes "^FF0000"+.@CDnicks$+"^000000";
     close;
    }
    
    ~3 before
      
     Zeny -= .register_cost;
     announce "The party ["+ strcharinfo(1) +"] has started the MvP ladder game.", bc_all;
     set .party_id, getcharid(1);
     set .@time_enter, gettimetick(2);
    
    ~ afeter
    
     Zeny -= .register_cost;
     announce "The party ["+ strcharinfo(1) +"] has started the MvP ladder game.", bc_all;
     set .party_id, getcharid(1);
     set .@time_enter, gettimetick(2);
     set .@cooldown,60; //time in minute
    
    ~4 before
    
     announce "You have "+ .timeout +" minutes to complete "+ .totalround +" rounds.", bc_self;
     .@name$[.@c] = strcharinfo(0);
     .@c++;
    
    ~ afeter
    
     announce "You have "+ .timeout +" minutes to complete "+ .totalround +" rounds.", bc_self;
     .@name$[.@c] = strcharinfo(0);
     RoomCD = gettimetick(2)+(60*.@cooldown);
     .@c++;

    mvp_ladder.txt

  4. I was using this mod from the normal goddameit on windows (vs), but when I tried to compile in linux he accused the lack of a windows library: WINSOCK2.H

    would it be possible to convert the ping.c code for linux centos and maintain the same functionality?

    ping.c

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    #include <WINSOCK2.H>
    #define DEF_BUF_SIZE 1024  
    #define IP_HEADER_SIZE 20  
    #define ICMP_HEADER_SIZE 12    
    typedef struct _ICMP_HEADER  
    {  	
    	BYTE bType;
    	BYTE bCode;
    	USHORT nCheckSum;
    	USHORT nId;
    	USHORT nSequence;
    	UINT nTimeStamp;
    }ICMP_HEADER, *PICMP_HEADER;    
    USHORT GetCheckSum(LPBYTE lpBuff, DWORD dwSize)
    {
    	DWORD dwCheckSum = 0;
    	USHORT* lpWord = (USHORT*)lpBuff;  
    	while(dwSize > 1)  	
    	{  		
    		dwCheckSum += *lpWord++;
    		dwSize -= 2;
    	}  	
    	if(dwSize ==1)  	
    		dwCheckSum += *((LPBYTE)lpBuff);
    	dwCheckSum = (dwCheckSum >> 16) + (dwCheckSum & 0XFFFF);
    	return (USHORT)(~dwCheckSum);  
    }    
    BOOL Ping(char* lpDestIP, int *nRet_, int *nTime_)
    {
    	int nTime = 0;
    	int ret = 0;
    	char ICMPPack[ICMP_HEADER_SIZE] = {0};
    	char szRcvBuff[DEF_BUF_SIZE] = {0};
    	int i = 0;
    	int nRet = 0;
    	int nLen = 0;
    	int nError = 0;
    	SOCKET s;
    	PICMP_HEADER pRcvHeader;
    	SOCKADDR_IN SourceSockAddr;
    	SOCKADDR_IN DestSockAddr;
    	PICMP_HEADER pICMPHeader;
    	DestSockAddr.sin_family = AF_INET;
    	DestSockAddr.sin_addr.S_un.S_addr = inet_addr(lpDestIP);
    	DestSockAddr.sin_port = htons(0);
    	pICMPHeader = (PICMP_HEADER)ICMPPack;  
    	pICMPHeader->bType = 8;
    	pICMPHeader->bCode = 0;
    	pICMPHeader->nId = (USHORT)GetCurrentProcessId();
    	pICMPHeader->nCheckSum = 0;
    	pICMPHeader->nTimeStamp = 0;
    	s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
    	nTime = 1000;
    	ret = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&nTime, sizeof(nTime));
    	for(i=0; i <1; i++)  	
    	{  		
    	pICMPHeader->nCheckSum = 0;
    		pICMPHeader->nSequence = i;
    		pICMPHeader->nTimeStamp = GetTickCount();
    		pICMPHeader->nCheckSum = GetCheckSum((LPBYTE)(ICMPPack), ICMP_HEADER_SIZE);
    		nRet = sendto(s, ICMPPack, ICMP_HEADER_SIZE, 0, (SOCKADDR*)&DestSockAddr, sizeof(DestSockAddr)); 
    		if(nRet == SOCKET_ERROR)
    		{ 
    			return FALSE;
    		}  		
    		nLen = sizeof(SOCKADDR_IN);
    		if(nRet == SOCKET_ERROR)
    		{
    			return FALSE;
    		}
    		nRet = recvfrom(s, szRcvBuff,DEF_BUF_SIZE,0,(SOCKADDR*)&SourceSockAddr,&nLen);
    		if(nRet == SOCKET_ERROR)
    		{
    			return FALSE;
    		}
    		pRcvHeader = (PICMP_HEADER)(szRcvBuff + IP_HEADER_SIZE);
    		nTime = GetTickCount() - pRcvHeader->nTimeStamp;
    		//printf("Return Message: %s bytes=%d time=%dms\n", inet_ntoa(SourceSockAddr.sin_addr), nRet, nTime);
    		*nRet_ = nRet;
    		*nTime_ = nTime;
    	}
    	return TRUE;
    }

     

  5. 20 minutes ago, Surefirer said:

    Hello, I have a custom instance, when the player disconnect or logout the game, when they log in again, I want the character back to the instance map, so they can continue enjoy the game, however it only allow re-enter the instance map once. hope you understand, if not I will try explain more detail.

    in this case warp will not work since it is an instance, it would have to be instance_enter, or am i mistaken?
    I will make a model and send it here...

×
×
  • Create New...