SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 02/02/2009, 05:20 AM   #151
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Useful Snippets

SetTimer returns the id of the timer. What about timerid 0?
Backwardsman97 is offline   Reply With Quote
Old 02/02/2009, 05:40 AM   #152
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: Useful Snippets

Maybe it's because he wants the guy he helps to really understand what he puts in?
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 02/02/2009, 05:58 AM   #153
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Useful Snippets

Quote:
Originally Posted by <3 HardStyle <3 | LarzI
Maybe it's because he wants the guy he helps to really understand what he puts in?
What? I mean, he checks to see if the timer is going by checking if the current timer id is above 0. I'm asking, what if the timerid is 0?
Backwardsman97 is offline   Reply With Quote
Old 02/02/2009, 05:59 AM   #154
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: Useful Snippets

Ahhh
I misunderstanded your question, my bad
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 02/02/2009, 06:16 AM   #155
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 788
Reputation: 4
Default Re: Useful Snippets

I check if it's true not that it's above zero and timers start at one.
__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline   Reply With Quote
Old 05/02/2009, 01:35 PM   #156
CracK
Huge Clucker
 
CracK's Avatar
 
Join Date: Nov 2007
Posts: 438
Reputation: 3
Default Re: Useful Snippets

Back\frontflip for bikes (Northwind bug workaround)
pawn Code:
if(strcmp(cmd, "/ftw", true) == 0 && IsPlayerInAnyVehicle(playerid))
{
    new v;
    v = GetVehicleModel(GetPlayerVehicleID(playerid));
    switch(v)
    {
      case 586,468,448,461,522,510,463,521,462,481,509,581:
      {
        new Float:z;
        GetVehicleZAngle(GetPlayerVehicleID(playerid),z);
        if(z > 320.0 || z < 33.0) SetVehicleZAngle(GetPlayerVehicleID(playerid),0);
        else if(z > 140.0 && z < 220.0) SetVehicleZAngle(GetPlayerVehicleID(playerid),180);
        else SendClientMessage(playerid,COLOR_RED," Turn yourself to the north (letter N on the map) or to the south");
        return 1;
      }
    }
    return 0;
}

Simply type /ftw on a skyscraper(for ex.) and drive forward without turning right or left. You can make a back\frontflip while flying down.

P.S. say thanks to someone, who posted a video on youtube, explaining how to do flips. I only made a command for this.
__________________
Custom Enex loader 1.0
map2pwn
CracK is offline   Reply With Quote
Old 10/02/2009, 06:02 PM   #157
Extremo
Gangsta
 
Extremo's Avatar
 
Join Date: Jul 2008
Posts: 717
Reputation: 90
Default Re: Useful Snippets

Thought somebody MIGHT find this useful:

pawn Code:
#define STR_LENGTH 64 // original length of a string = 50, 14 are always internly in use, so if you need 100 char, you'll have to use 114

// Changes the defines below to the NAMES of the needed enums, for example #define define1 Kills
#define str_define1 str_Kills
#define str_define2 str_1
#define str_define3 str_3
#define str_define4 str_4
#define str_define5 str_5
#define str_define6 str_6
#define str_define7 str_7
#define str_define8 str_8
#define str_define9 str_9
#define str_define10 str_10
#define str_define11 str_11
#define str_define12 str_12
#define str_define13 str_13
#define str_define14 str_14
#define str_define15 str_15
#define str_define16 str_16
#define str_define17 str_17
#define str_define18 str_18
#define str_define19 str_19
#define str_define20 str_20
#define str_define21 str_21
#define str_define22 str_22
#define str_define23 str_23
#define str_define24 str_24
#define str_define25 str_25
#define str_define26 str_26
#define str_define27 str_27
#define str_define28 str_28
#define str_define29 str_29
#define str_define30 str_30
#define str_define31 str_31
#define str_define32 str_32
#define str_define33 str_33
#define str_define34 str_34
#define str_define35 str_35
#define str_define36 str_36
#define str_define37 str_37
#define str_define38 str_38
#define str_define39 str_39
#define str_define40 str_40
#define str_define41 str_41
#define str_define42 str_42
#define str_define43 str_43
#define str_define44 str_44
#define str_define45 str_45
#define str_define46 str_46
#define str_define47 str_47
#define str_define48 str_48
#define str_define49 str_49
#define str_define50 str_50


new
            str_define1[MAX_PLAYERS][STR_LENGTH],
            str_define2[MAX_PLAYERS][STR_LENGTH],
            str_define3[MAX_PLAYERS][STR_LENGTH],
            str_define4[MAX_PLAYERS][STR_LENGTH],
            str_define5[MAX_PLAYERS][STR_LENGTH],
            str_define6[MAX_PLAYERS][STR_LENGTH],
            str_define7[MAX_PLAYERS][STR_LENGTH],
            str_define8[MAX_PLAYERS][STR_LENGTH],
            str_define9[MAX_PLAYERS][STR_LENGTH],
            str_define10[MAX_PLAYERS][STR_LENGTH],
            str_define11[MAX_PLAYERS][STR_LENGTH],
            str_define12[MAX_PLAYERS][STR_LENGTH],
            str_define13[MAX_PLAYERS][STR_LENGTH],
            str_define14[MAX_PLAYERS][STR_LENGTH],
            str_define15[MAX_PLAYERS][STR_LENGTH],
            str_define16[MAX_PLAYERS][STR_LENGTH],
            str_define17[MAX_PLAYERS][STR_LENGTH],
            str_define18[MAX_PLAYERS][STR_LENGTH],
            str_define19[MAX_PLAYERS][STR_LENGTH],
            str_define20[MAX_PLAYERS][STR_LENGTH],
            str_define21[MAX_PLAYERS][STR_LENGTH],
            str_define22[MAX_PLAYERS][STR_LENGTH],
            str_define23[MAX_PLAYERS][STR_LENGTH],
            str_define24[MAX_PLAYERS][STR_LENGTH],
            str_define25[MAX_PLAYERS][STR_LENGTH],
            str_define26[MAX_PLAYERS][STR_LENGTH],
            str_define27[MAX_PLAYERS][STR_LENGTH],
            str_define28[MAX_PLAYERS][STR_LENGTH],
            str_define29[MAX_PLAYERS][STR_LENGTH],
            str_define30[MAX_PLAYERS][STR_LENGTH],
            str_define31[MAX_PLAYERS][STR_LENGTH],
            str_define32[MAX_PLAYERS][STR_LENGTH],
            str_define33[MAX_PLAYERS][STR_LENGTH],
            str_define34[MAX_PLAYERS][STR_LENGTH],
            str_define35[MAX_PLAYERS][STR_LENGTH],
            str_define36[MAX_PLAYERS][STR_LENGTH],
            str_define37[MAX_PLAYERS][STR_LENGTH],
            str_define38[MAX_PLAYERS][STR_LENGTH],
            str_define39[MAX_PLAYERS][STR_LENGTH],
            str_define40[MAX_PLAYERS][STR_LENGTH],
            str_define41[MAX_PLAYERS][STR_LENGTH],
            str_define42[MAX_PLAYERS][STR_LENGTH],
            str_define43[MAX_PLAYERS][STR_LENGTH],
            str_define44[MAX_PLAYERS][STR_LENGTH],
            str_define45[MAX_PLAYERS][STR_LENGTH],
            str_define46[MAX_PLAYERS][STR_LENGTH],
            str_define47[MAX_PLAYERS][STR_LENGTH],
            str_define48[MAX_PLAYERS][STR_LENGTH],
            str_define49[MAX_PLAYERS][STR_LENGTH],
            str_define50[MAX_PLAYERS][STR_LENGTH];


#define setvalue(%1,%2,%3); format(str_%1[%2],STR_LENGTH,"%d",%3); // use this like: setvalue(Kills,PlayerID,1);
#define setstring(%1,%2,%3); format(str_%1[%2],STR_LENGTH,%3); // setstring(Kills,PlayerID,"twenty");
#define getvalue(%1,%2) strval(str_%1[%2]) // getvalue(Kills,PlayerID);
#define getstring(%1,%2) str_%1[%2] // getstring(Kills,PlayerID);
I know its retarded but meh.
__________________
Extremo is offline   Reply With Quote
Old 12/02/2009, 11:49 AM   #158
[RP]Rav
Huge Clucker
 
Join Date: Oct 2007
Posts: 262
Reputation: 0
Default Re: Useful Snippets

A small (somewhat useful) snippet of code, this function finds and parses a player name according to certain rules.. For example: [CLAN]Rav_Is_Awesome would simply become "Rav Is Awesome" in the chat, a gimmick for roleplay servers I guess

Code:
stock PlayerName(playerid, parse = false)
{
	new name[32];
	GetPlayerName(playerid,name,32);
	
	if(parse)
	{
		new idx = strfind(name,"_",true);
		if(idx > -1)
			name[idx] = ' ';

	  idx = strfind(name,"[",true);
	  new idx2 = strfind(name,"]",true);
	  if (idx2 > idx && idx2 < strlen(name))
	    strdel(name,idx,idx2+1);
	}
	
	return name;
}
using it is really simple, if you don't want the names to be parsed use
Code:
PlayerName(playerid)
if you do
Code:
PlayerName(playerid, true)

down to the good stuff now, strsplit.. this splits a string into multiple strings, which can be useful if you've stored things in a file in this way:
Quote:
value,value,value,value,value,value
Code:
stock strsplit(const string[],destination[][],delimiter)
{
	new lastIndex, arrayNum, cell;
	for (new i; i <= strlen(string); i++)
		if (string[i] == delimiter || i == strlen(string))
		{
			cell = strmid(destination[arrayNum], string, lastIndex, i, 128);
			destination[arrayNum][cell] = 0; // clear!
			lastIndex = i + 1;
			arrayNum++;
		}

	return 1;
}
[RP]Rav is offline   Reply With Quote
Old 12/02/2009, 05:50 PM   #159
boylett
Huge Clucker
 
Join Date: Jul 2006
Posts: 441
Reputation: 0
Default Re: Useful Snippets

More of a "Useful Function" imo
boylett is offline   Reply With Quote
Old 02/03/2009, 10:04 AM   #160
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Snippets

Quote:
Originally Posted by Rav
A small (somewhat useful) snippet of code, this function finds and parses a player name according to certain rules.. For example: [CLAN]Rav_Is_Awesome would simply become "Rav Is Awesome" in the chat, a gimmick for roleplay servers I guess

Code:
stock PlayerName(playerid, parse = false)
{
	new name[32];
	GetPlayerName(playerid,name,32);
	
	if(parse)
	{
		new idx = strfind(name,"_",true);
		if(idx > -1)
			name[idx] = ' ';

	  idx = strfind(name,"[",true);
	  new idx2 = strfind(name,"]",true);
	  if (idx2 > idx && idx2 < strlen(name))
	    strdel(name,idx,idx2+1);
	}
	
	return name;
}
using it is really simple, if you don't want the names to be parsed use
Code:
PlayerName(playerid)
if you do
Code:
PlayerName(playerid, true)

down to the good stuff now, strsplit.. this splits a string into multiple strings, which can be useful if you've stored things in a file in this way:
Quote:
value,value,value,value,value,value
Code:
stock strsplit(const string[],destination[][],delimiter)
{
	new lastIndex, arrayNum, cell;
	for (new i; i <= strlen(string); i++)
		if (string[i] == delimiter || i == strlen(string))
		{
			cell = strmid(destination[arrayNum], string, lastIndex, i, 128);
			destination[arrayNum][cell] = 0; // clear!
			lastIndex = i + 1;
			arrayNum++;
		}

	return 1;
}
It's so long :>, my function has less lines.
pawn Code:
PlayerName(playerid)
{
  new n[24];
  GetPlayerName(playerid,n,24);
  for(new i=0;i<MAX_PLAYERS;i++)
  if(n[i]=='_') n[i]=' ';
  return n;
}
MenaceX^ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
READ Usefull Links to snippets and other -Sneaky- Help Archive 5 02/05/2009 12:22 PM


All times are GMT. The time now is 07:28 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.