This site has been archived and made available for preservation purposes. No edits can be made.

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Useful Function Thread (Frequently updated)

  1. #11
    Senior Member Dantiko's Avatar
    Join Date
    Aug 2011
    Location
    São Carlos, Brazil
    Posts
    452

    Re: Useful Function Thread (Frequently updated)

    Also something you must add before launching the next version, the 32 player server said there were 0 players, when I entered I saw a guy, and I killed him, also, the same thing happened on the 0.1 test server, the same guy, but he disappeared.IDK maybe he entered after me in the server.
    "Only a few don't give up on games, and only a few give up on life"

  2. #12

    Re: Useful Function Thread (Frequently updated)

    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    it's 16 bit right? most likely. change it to 65535

  3. #13

    Re: Useful Function Thread (Frequently updated)

    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    TBH, I wouldn't even wanna move to the new PAWN they're currently on. They've removed so many great things like enumerators. Not really sure it if it's true but I'd recommend using the PAWN version that was made about 5 - 3 years ago.
    A gaming community ran by one person, with servers made by individuals (in this case, me, myself)
    I plan to look for a trusted person who will help me create a decent roleplay/deathmatch server on Vault-TEC,
    PM me if you're interested

  4. #14

    Re: Useful Function Thread (Frequently updated)

    [quote author=Lorenc link=topic=33.msg935#msg935 date=1313768296]
    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    TBH, I wouldn't even wanna move to the new PAWN they're currently on. They've removed so many great things like enumerators. Not really sure it if it's true but I'd recommend using the PAWN version that was made about 5 - 3 years ago.
    [/quote]

    to use an enum in the lastest pawn, just replace "enum ..." with "const ..."

    is it so hard?

    Code :
    stock Times_String_Repeated( strSrc[], strWhat[], bool:casesensitive = true)
    {
      new Times = 0, pos = -1;
      while((pos = strfind(strSrc, strWhat, casesensitive, (pos + 1))) != -1) Times ++;
    	return Times;
    }
     
    stock getDigits(const value, strDig[]) //by RyDeR`
    {
      valstr(strDig, value, true);
      for(new i; strDig{i} != EOS; ++i) strDig{i} -= '0';
    } 
     
    stock explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])//not by me
    {
    	new iNode, iPointer, iPrevious = -1, iDelimiter = strlen(sDelimiter);
    	while(iNode < iVertices)
    	{
    		iPointer = strfind(sSource, sDelimiter, false, iPointer);
    		if(iPointer == -1)
    		{
    			strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
    			break;
    		}
    		else strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
    		iPrevious = (iPointer += iDelimiter);
    		++iNode;
    	}
    	return iPrevious;
    }
    stock SplitEx(strsrc[], strdest[][], delimiter) // Credits to original author
    {
      new i, li, aNum, len;
      while(i <= strlen(strsrc))
      {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
          len = strmid(strdest[aNum], strsrc, li, i, 92);
          strdest[aNum][len] = 0;
          li = i + 1;
          aNum++;
        }
        i++;
      }
      return 1;
    }
    stock StripStringOfNonNumbers(string[], const ichar[] = "", const size = sizeof ichar)
    {
      new c, i, j, idx, length = strlen(string);
      for( ; i != length; ++i) {
        c = string[i];
        if('0' <= c <= '9') string[idx++] = c;
        else {
          for(j = size - 1; j != -1; --j) {
            if(c == ichar[j]) {
              string[idx++] = c;
              break;
            }
          }
        }
      }
      string[idx] = EOS;
      return false;
    }
     
    stock bool:str_in_array(const sNeedle[], const aHaystack[][], const iHaystack = sizeof aHaystack)//by westie
    {
    	new iNode = 0;
    	while(iNode < iHaystack)
    	{
    		if(!strcmp(sNeedle, aHaystack[iNode], true)) return true;
    		++iNode;
    	}
    	return false;
    }
    stock PlayerInsert(text[], rchar = '%')
    {
      new length = strlen(text);
      for(new a = 0; a < length; a++)
      {
        if(text[a] == rchar && IsCharNumeric(text[a+1]) && text[a+1] != EOS)
        {
          if(IsPlayerConnected(strval(text[a+1])))
          {
            strdel(text[a], 0, 2);
            strins(text[a], Playername(strval(text[a+1])), 0);
          }
        }
      }
    }

  5. #15

    Re: Useful Function Thread (Frequently updated)

    [quote author=Kar link=topic=33.msg1268#msg1268 date=1314395423]
    [quote author=Lorenc link=topic=33.msg935#msg935 date=1313768296]
    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    TBH, I wouldn't even wanna move to the new PAWN they're currently on. They've removed so many great things like enumerators. Not really sure it if it's true but I'd recommend using the PAWN version that was made about 5 - 3 years ago.
    [/quote]

    to use an enum in the lastest pawn, just replace "enum ..." with "const ..."

    is it so hard?

    Code :
    stock Times_String_Repeated( strSrc[], strWhat[], bool:casesensitive = true)
    {
      new Times = 0, pos = -1;
      while((pos = strfind(strSrc, strWhat, casesensitive, (pos + 1))) != -1) Times ++;
      return Times;
    }
     
    stock getDigits(const value, strDig[]) //by RyDeR`
    {
      valstr(strDig, value, true);
      for(new i; strDig{i} != EOS; ++i) strDig{i} -= '0';
    } 
     
    stock explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])//not by me
    {
      new iNode, iPointer, iPrevious = -1, iDelimiter = strlen(sDelimiter);
      while(iNode < iVertices)
      {
       iPointer = strfind(sSource, sDelimiter, false, iPointer);
       if(iPointer == -1)
       {
         strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
         break;
       }
       else strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
       iPrevious = (iPointer += iDelimiter);
       ++iNode;
      }
      return iPrevious;
    }
    stock SplitEx(strsrc[], strdest[][], delimiter) // Credits to original author
    {
      new i, li, aNum, len;
      while(i <= strlen(strsrc))
      {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
          len = strmid(strdest[aNum], strsrc, li, i, 92);
          strdest[aNum][len] = 0;
          li = i + 1;
          aNum++;
        }
        i++;
      }
      return 1;
    }
    stock StripStringOfNonNumbers(string[], const ichar[] = "", const size = sizeof ichar)
    {
      new c, i, j, idx, length = strlen(string);
      for( ; i != length; ++i) {
        c = string[i];
        if('0' <= c <= '9') string[idx++] = c;
        else {
          for(j = size - 1; j != -1; --j) {
            if(c == ichar[j]) {
              string[idx++] = c;
              break;
            }
          }
        }
      }
      string[idx] = EOS;
      return false;
    }
     
    stock bool:str_in_array(const sNeedle[], const aHaystack[][], const iHaystack = sizeof aHaystack)//by westie
    {
      new iNode = 0;
      while(iNode < iHaystack)
      {
       if(!strcmp(sNeedle, aHaystack[iNode], true)) return true;
       ++iNode;
      }
      return false;
    }
    stock PlayerInsert(text[], rchar = '%')
    {
      new length = strlen(text);
      for(new a = 0; a < length; a++)
      {
        if(text[a] == rchar && IsCharNumeric(text[a+1]) && text[a+1] != EOS)
        {
          if(IsPlayerConnected(strval(text[a+1])))
          {
            strdel(text[a], 0, 2);
            strins(text[a], Playername(strval(text[a+1])), 0);
          }
        }
      }
    }
    [/quote]
    The syntax is quite different, it is going to be hard to get used to it for him I guess..


    I just come here to view whether there has been any progress or not, and review the wonderful progress that Recycler and the development team has made.
    My sincere thanks goes to them and to others who value my contributions the community, not to mention the ones that solely contribute.

  6. #16

    Re: Useful Function Thread (Frequently updated)

    [quote author=Kar link=topic=33.msg1268#msg1268 date=1314395423]
    [quote author=Lorenc link=topic=33.msg935#msg935 date=1313768296]
    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    TBH, I wouldn't even wanna move to the new PAWN they're currently on. They've removed so many great things like enumerators. Not really sure it if it's true but I'd recommend using the PAWN version that was made about 5 - 3 years ago.
    [/quote]

    to use an enum in the lastest pawn, just replace "enum ..." with "const ..."

    is it so hard?

    Code :
    stock Times_String_Repeated( strSrc[], strWhat[], bool:casesensitive = true)
    {
      new Times = 0, pos = -1;
      while((pos = strfind(strSrc, strWhat, casesensitive, (pos + 1))) != -1) Times ++;
    	return Times;
    }
     
    stock getDigits(const value, strDig[]) //by RyDeR`
    {
      valstr(strDig, value, true);
      for(new i; strDig{i} != EOS; ++i) strDig{i} -= '0';
    } 
     
    stock explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])//not by me
    {
    	new iNode, iPointer, iPrevious = -1, iDelimiter = strlen(sDelimiter);
    	while(iNode < iVertices)
    	{
    		iPointer = strfind(sSource, sDelimiter, false, iPointer);
    		if(iPointer == -1)
    		{
    			strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
    			break;
    		}
    		else strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
    		iPrevious = (iPointer += iDelimiter);
    		++iNode;
    	}
    	return iPrevious;
    }
    stock SplitEx(strsrc[], strdest[][], delimiter) // Credits to original author
    {
      new i, li, aNum, len;
      while(i <= strlen(strsrc))
      {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
          len = strmid(strdest[aNum], strsrc, li, i, 92);
          strdest[aNum][len] = 0;
          li = i + 1;
          aNum++;
        }
        i++;
      }
      return 1;
    }
    stock StripStringOfNonNumbers(string[], const ichar[] = "", const size = sizeof ichar)
    {
      new c, i, j, idx, length = strlen(string);
      for( ; i != length; ++i) {
        c = string[i];
        if('0' <= c <= '9') string[idx++] = c;
        else {
          for(j = size - 1; j != -1; --j) {
            if(c == ichar[j]) {
              string[idx++] = c;
              break;
            }
          }
        }
      }
      string[idx] = EOS;
      return false;
    }
     
    stock bool:str_in_array(const sNeedle[], const aHaystack[][], const iHaystack = sizeof aHaystack)//by westie
    {
    	new iNode = 0;
    	while(iNode < iHaystack)
    	{
    		if(!strcmp(sNeedle, aHaystack[iNode], true)) return true;
    		++iNode;
    	}
    	return false;
    }
    stock PlayerInsert(text[], rchar = '%')
    {
      new length = strlen(text);
      for(new a = 0; a < length; a++)
      {
        if(text[a] == rchar && IsCharNumeric(text[a+1]) && text[a+1] != EOS)
        {
          if(IsPlayerConnected(strval(text[a+1])))
          {
            strdel(text[a], 0, 2);
            strins(text[a], Playername(strval(text[a+1])), 0);
          }
        }
      }
    }
    [/quote]

    hahaha Didn't relise. I'll add those functions soon though
    A gaming community ran by one person, with servers made by individuals (in this case, me, myself)
    I plan to look for a trusted person who will help me create a decent roleplay/deathmatch server on Vault-TEC,
    PM me if you're interested

  7. #17

    Re: Useful Function Thread (Frequently updated)

    [quote author=Aleksander link=topic=33.msg1274#msg1274 date=1314406366]
    [quote author=Kar link=topic=33.msg1268#msg1268 date=1314395423]
    [quote author=Lorenc link=topic=33.msg935#msg935 date=1313768296]
    [quote author=Recycler link=topic=33.msg721#msg721 date=1312921822]
    999 ping usually means that the mod failed to ping the server (I have to change that 999 to something else). The only "official" servers are those named "vaultmp 0.1a testserver", you should be able to properly ping them

    BTW, the next revision will come with the updated version of PAWN. Scripters may want to check this: https://www.compuphase.com/pawn/pawnhistory.htm
    [/quote]

    TBH, I wouldn't even wanna move to the new PAWN they're currently on. They've removed so many great things like enumerators. Not really sure it if it's true but I'd recommend using the PAWN version that was made about 5 - 3 years ago.
    [/quote]

    to use an enum in the lastest pawn, just replace "enum ..." with "const ..."

    is it so hard?

    Code :
    stock Times_String_Repeated( strSrc[], strWhat[], bool:casesensitive = true)
    {
      new Times = 0, pos = -1;
      while((pos = strfind(strSrc, strWhat, casesensitive, (pos + 1))) != -1) Times ++;
      return Times;
    }
     
    stock getDigits(const value, strDig[]) //by RyDeR`
    {
      valstr(strDig, value, true);
      for(new i; strDig{i} != EOS; ++i) strDig{i} -= '0';
    } 
     
    stock explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])//not by me
    {
      new iNode, iPointer, iPrevious = -1, iDelimiter = strlen(sDelimiter);
      while(iNode < iVertices)
      {
       iPointer = strfind(sSource, sDelimiter, false, iPointer);
       if(iPointer == -1)
       {
         strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
         break;
       }
       else strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
       iPrevious = (iPointer += iDelimiter);
       ++iNode;
      }
      return iPrevious;
    }
    stock SplitEx(strsrc[], strdest[][], delimiter) // Credits to original author
    {
      new i, li, aNum, len;
      while(i <= strlen(strsrc))
      {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
          len = strmid(strdest[aNum], strsrc, li, i, 92);
          strdest[aNum][len] = 0;
          li = i + 1;
          aNum++;
        }
        i++;
      }
      return 1;
    }
    stock StripStringOfNonNumbers(string[], const ichar[] = "", const size = sizeof ichar)
    {
      new c, i, j, idx, length = strlen(string);
      for( ; i != length; ++i) {
        c = string[i];
        if('0' <= c <= '9') string[idx++] = c;
        else {
          for(j = size - 1; j != -1; --j) {
            if(c == ichar[j]) {
              string[idx++] = c;
              break;
            }
          }
        }
      }
      string[idx] = EOS;
      return false;
    }
     
    stock bool:str_in_array(const sNeedle[], const aHaystack[][], const iHaystack = sizeof aHaystack)//by westie
    {
      new iNode = 0;
      while(iNode < iHaystack)
      {
       if(!strcmp(sNeedle, aHaystack[iNode], true)) return true;
       ++iNode;
      }
      return false;
    }
    stock PlayerInsert(text[], rchar = '%')
    {
      new length = strlen(text);
      for(new a = 0; a < length; a++)
      {
        if(text[a] == rchar && IsCharNumeric(text[a+1]) && text[a+1] != EOS)
        {
          if(IsPlayerConnected(strval(text[a+1])))
          {
            strdel(text[a], 0, 2);
            strins(text[a], Playername(strval(text[a+1])), 0);
          }
        }
      }
    }
    [/quote]
    The syntax is quite different, it is going to be hard to get used to it for him I guess..
    [/quote]

    It's not that much updated, you can really make a enum using 2 (3?) different ways now, all you have to do is get the enum finished, the easiest way would be to just replace enum with const and there you go, no need to change the main variable

  8. #18
    Senior Member Dantiko's Avatar
    Join Date
    Aug 2011
    Location
    São Carlos, Brazil
    Posts
    452

    Re: Useful Function Thread (Frequently updated)

    Hm, will there be save data(server side)?
    "Only a few don't give up on games, and only a few give up on life"

  9. #19

    Re: Useful Function Thread (Frequently updated)

    [quote author=Dantiko link=topic=33.msg1649#msg1649 date=1314807005]
    Hm, will there be save data(server side)?
    [/quote]

    No, you will need to script that using the file functions. I hope to release a simple file writer soon.
    A gaming community ran by one person, with servers made by individuals (in this case, me, myself)
    I plan to look for a trusted person who will help me create a decent roleplay/deathmatch server on Vault-TEC,
    PM me if you're interested

  10. #20

    Re: Useful Function Thread (Frequently updated)

    [quote author=Lorenc link=topic=33.msg129#msg129 date=1309070914]
    Code :
    #if !defined MAX_PLAYER_NAME
    	#define MAX_PLAYER_NAME 24 // 24 Characters, I don't know the limit yet...
    #endif
    stock ReturnPlayerName(clientid)
    {
    	new name[MAX_PLAYER_NAME];
    	GetPlayerName(clientid, name);
    	return name;
    }
    [/quote]
    Would be better so store it in a global variable and check the name while connecting

Similar Threads

  1. ReplaceChars Function
    By Aeronix in forum PAWN
    Replies: 1
    Last Post: 09-03-2011, 06:35 PM
  2. New Forum Thread
    By Dantiko in forum Suggestions
    Replies: 0
    Last Post: 08-08-2011, 10:22 PM
  3. The Pawn Language has updated.
    By Kar in forum Discussion
    Replies: 1
    Last Post: 08-04-2011, 07:48 PM
  4. suggestion: new forum thread
    By shorun in forum Suggestions
    Replies: 0
    Last Post: 08-04-2011, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •