SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 31/10/2018, 05:47 PM   #1301
Heress
Huge Clucker
 
Heress's Avatar
 
Join Date: Mar 2018
Location: Lithuania
Posts: 211
Reputation: 7
Default Re: Useful Snippets

deleted
__________________
==============
Sorry for my bad English









Respect: Kalcor, Y_Less. Thank you for this great game!
Heress is online now   Reply With Quote
Old 09/11/2018, 09:41 AM   #1302
Riddick94
High-roller
 
Riddick94's Avatar
 
Join Date: Mar 2010
Location: Poland
Posts: 1,930
Reputation: 218
Default Re: Useful Snippets

Animations data: LIBRARY | NAME | INDEX

Data
https://pastebin.com/raw/eqrJX5KD

I wanted to put that up on wiki page, but apparently people are unable to login to wiki.

----
I was looking for that, but couldn't find it at all (even at not SA-MP's related pages).
I find that really useful to determine if player uses specific animation (better than using string comparision for animation names).

Additionally useful for FCNPC_SetAnimation function from FCNPC (which requires animation index).

edit://
Now on WIKI:
https://wiki.sa-mp.com/wiki/Animations#WEAPONS
__________________



Last edited by Riddick94; 13/02/2019 at 02:13 PM.
Riddick94 is offline   Reply With Quote
Old 24/01/2019, 06:05 PM   #1303
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 312
Reputation: 77
Default Re: Useful Snippets

HitMarker:

PHP Code:
#include <a_samp>

static Text:aim_hit_td;
static 
aim_show[MAX_PLAYERS] = {false,...};

static const 
nweps[] =
{
    
0123456789101112131415161718,
    
343539414243
};

public 
OnFilterScriptInit()
{
    
aim_hit_td TextDrawCreate(336.400512176.088546"x");
    
TextDrawLetterSize(aim_hit_td0.2639980.629333);
    
TextDrawTextSize(aim_hit_td, -8.0000000.000000);
    
TextDrawAlignment(aim_hit_td1);
    
TextDrawColor(aim_hit_td, -16776961);
    
TextDrawSetShadow(aim_hit_td0);
    
TextDrawBackgroundColor(aim_hit_td255);
    
TextDrawFont(aim_hit_td1);
    
TextDrawSetProportional(aim_hit_td1);
    return 
1;
}

public 
OnPlayerDisconnect(playeridreason)
{
    
aim_show[playerid] = false;
    return 
1;
}

public 
OnFilterScriptExit()
{
    
TextDrawDestroy(aim_hit_td);
    return 
1;
}

public 
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    for(new 
0sizeof(nweps); i++)
    {
        if(
weaponid == nweps[i]) return 0;
    }
    if(
issuerid != 0xFFFF && !IsPlayerNPC(issuerid) && !aim_show[issuerid])
    {
        
TextDrawShowForPlayer(issueridaim_hit_td);
        
SetTimerEx("HideTD"200false"i"issuerid);
        
aim_show[issuerid] = true;
    }
    return 
0;
}

forward HideTD(playerid);

public 
HideTD(playerid)
{
    
TextDrawHideForPlayer(playeridaim_hit_td);
    
aim_show[playerid] = false;
    return 
1;

Lokii is offline   Reply With Quote
Old 02/02/2019, 06:15 PM   #1304
SymonClash
Big Clucker
 
SymonClash's Avatar
 
Join Date: Dec 2018
Posts: 133
Reputation: 8
Default Re: Useful Snippets

Quote:
Originally Posted by Lokii View Post
HitMarker:
What does?
SymonClash is offline   Reply With Quote
Old 02/02/2019, 06:27 PM   #1305
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 312
Reputation: 77
Default Re: Useful Snippets

Quote:
Originally Posted by SymonClash View Post
What does?
Show red X on aim when you shoot players
Lokii is offline   Reply With Quote
Old 07/02/2019, 06:45 PM   #1306
Kasichok
Little Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 39
Reputation: 12
Default Re: Useful Snippets



Time script



PHP Code:
#include <a_samp>

static timer;
static 
Text:time;

public 
OnFilterScriptInit()
{
    
time TextDrawCreate(552.90020732.800006"00:00");
    
TextDrawLetterSize(time0.4103332.321777);
    
TextDrawAlignment(time1);
    
TextDrawColor(time255);
    
TextDrawSetShadow(time0);
    
TextDrawSetOutline(time1);
    
TextDrawBackgroundColor(time, -2139062017);
    
TextDrawFont(time0);
    
TextDrawSetProportional(time1);
    
timer SetTimer("Update_Time"1000true);
    return 
1;
}

public 
OnFilterScriptExit()
{
    
TextDrawDestroy(time);
    
KillTimer(timer);
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
TextDrawShowForPlayer(playeridtime);
    return 
1;
}

forward Update_Time();

public 
Update_Time()
{
    new 
str[6], hm;
    
gettime(hm);
    
format(strsizeof(str), "%02d:%02d"hm);
    
TextDrawSetString(timestr);
    return 
1;

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 11/02/2019, 06:28 AM   #1307
Riddick94
High-roller
 
Riddick94's Avatar
 
Join Date: Mar 2010
Location: Poland
Posts: 1,930
Reputation: 218
Default Re: Useful Snippets

Quote:
Originally Posted by Kasichok View Post


Time script

[image]...[/image]

PHP Code:
#include <a_samp>

static timer;
static 
Text:time;

public 
OnFilterScriptInit()
{
    
time TextDrawCreate(552.90020732.800006"00:00");
    
TextDrawLetterSize(time0.4103332.321777);
    
TextDrawAlignment(time1);
    
TextDrawColor(time255);
    
TextDrawSetShadow(time0);
    
TextDrawSetOutline(time1);
    
TextDrawBackgroundColor(time, -2139062017);
    
TextDrawFont(time0);
    
TextDrawSetProportional(time1);
    
timer SetTimer("Update_Time"1000true);
    return 
1;
}

public 
OnFilterScriptExit()
{
    
TextDrawDestroy(time);
    
KillTimer(timer);
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
TextDrawShowForPlayer(playeridtime);
    return 
1;
}

forward Update_Time();

public 
Update_Time()
{
    new 
str[6], hm;
    
gettime(hm);
    
format(strsizeof(str), "%02d:%02d"hm);
    
TextDrawSetString(timestr);
    return 
1;

https://en.wikipedia.org/wiki/Snippet_(programming)

Quote:
Originally Posted by Wikipedia
Snippet is a programming term for a small region of re-usable source code, machine code, or text. Ordinarily, these are formally defined operative units to incorporate into larger programming modules.

[...]
Explain me how's your a snippet?
__________________


Riddick94 is offline   Reply With Quote
Old 11/02/2019, 08:18 AM   #1308
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,725
Reputation: 3226
Default Re: Useful Snippets

Seems like one to me. How is it not?
Y_Less is online now   Reply With Quote
Old 15/02/2019, 08:22 PM   #1309
iamjems
Big Clucker
 
iamjems's Avatar
 
Join Date: Aug 2016
Location: Croatia
Posts: 122
Reputation: 7
Default Re: Useful Snippets

Replacing Discord mentions with the mentioned user's (nick)name


NOTE: dc_Guild must be the ID of your guild (Discord server).

PHP Code:
ReplaceDiscordMentions(const message[])
{    
    new 
DCC_User:mention_id
        
mention_name[33],
        
user[19],
        
string[166], 
        
pos;

    
format(stringsizeof(string), message);

    for(new 
isizeof(string); i++)
    {    
        if(
string[i] == '<' && string[1] == '@')
        {    
            
pos i;

            if(
string[2] == '!')
                
i++;

            
strmid(userstring221);

            
mention_id DCC_FindUserById(user);

            if(!
mention_id)
                continue;

            
DCC_GetGuildMemberNickname(dc_Guildmention_idmention_name);

            if(
isnull(mention_name))
                
DCC_GetUserName(mention_idmention_name);

            
format(mention_namesizeof(mention_name), "@%s"mention_name);

            
strdel(stringpospos 21 + (pos));
            
strins(stringmention_namepos);
        }
    }

    return 
string;

USAGE:

PHP Code:
public DCC_OnChannelMessage(DCC_Channel:channelDCC_User:author, const message[])
{
    if(
channel == yourDiscordChannel)
    {    
        
SendClientMessageToAll(-1ReplaceDiscordMentions(message));
    }

    return 
1;

This code will transform this:

hello <@172459264917204728>
OR
hello <@!172459264917204728>

to this:

hello @John

Last edited by iamjems; 16/02/2019 at 01:29 AM.
iamjems 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 09:44 PM.


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