SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/09/2018, 01:49 AM   #1151
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,498
Reputation: 314
Default Re: Useful Snippets

Make NPC respond to you
Code:
public OnPlayerText(playerid, text[])
{
    if (strfind(text, "I need a taxi") != -1)
    {
        new string[80], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
 new Float:X, Float:Y, Float:Z, Float:Angle;

        
        format(string, sizeof(string), "Hey %s taxi is in your way!", name);
        SendChat(string);
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
Createvehicle// here 
    }
    return 1;
}
Make NPC write a command

Code:
 public OnPlayerText(playerid, text[])
{
    if (strfind(text, "fuck you") != -1)
    {
        new string[80], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
 
        SendCommand("/kick %i", playerid);
        format(string, sizeof(string), "Hey %s Fuck off!", name); // you can set a timer so the player can see the message
        SendChat(string);
    }
    return 1;
}
Not sure if the last snippet will work since I wrote it off phone but neverthless itís funny how you can experiment with NPCs.
Also this is just an entertaining snippet.
Crystallize is offline   Reply With Quote
Old 23/10/2018, 01:24 AM   #1152
AmirSavand
Big Clucker
 
AmirSavand's Avatar
 
Join Date: Sep 2018
Location: Behind Schedule
Posts: 79
Reputation: 8
Default Re: Useful Snippets

Quote:
Originally Posted by brauf View Post
serverHang Hangs/pauses your server for what ever reason you would want it to.
param 1 = seconds
param 2 = bool


How it can be used:
Code:
If a server would like to release at a specific time, then they can convert seconds 
to mins by adding *3600 at the end their number (multiply by an hour). This will be good
if a server is having a opening beta release and they want their server to open/start at that
exact time, will the server is already running but not fully loaded. Place the function on
public OnGamemodeInit()
...
This is a terrible script. Some hosts may even disable your VPS if you're running at max CPU usage for a long time.
__________________

GitHub - Website - Contact

C# - Python - PHP - Angular
Unity 3D - Django - Electron

AmirSavand is offline   Reply With Quote
Old 31/10/2018, 03:12 PM   #1153
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 584
Reputation: 66
Default Re: Useful Snippets

Halloween accessories

First release on Github
pawn Code:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

CMD:halloween(playerid, params[])
{
    new option;
    if(sscanf(params, "d", option))
        {
            SendClientMessage(playerid, 0x8CAA63FF, "SYNTAX: {FFFFFF}/halloween 1 : Wizard Hat - 2 : Devil Mask");
            return SendClientMessage(playerid, 0x8CAA63FF, "DESCRIPTION: {FFFFFF}Used to attach either a hat or a mask on your head");
        }
   
    switch(option)
    {
        case 1:
        {
            if(IsPlayerAttachedObjectSlotUsed(playerid, 8))
                {
                    RemovePlayerAttachedObject(playerid, 8);
                    return SendClientMessage(playerid, 0x33CCFFFF, "INFO: {FFFFFF}You've just removed your Halloween hat successfully.");
                }
                 
            SetPlayerAttachedObject(playerid, 8, 19528, 2, 0.125, -0.015, 0.01, 0.0, 0.0, -32.5, 0.9, 0.84, 1.01, 0, 0);
            EditAttachedObject(playerid, 8);
            SendClientMessage(playerid, 0x33CCFFFF, "INFO: {FFFFFF}You've just put on your Halloween hat! You can remove it by retyping the command.");
        }
        case 2:
        {
            if(IsPlayerAttachedObjectSlotUsed(playerid, 9))
                {
                    RemovePlayerAttachedObject(playerid, 9);
                    return SendClientMessage(playerid, 0x33CCFFFF, "INFO: {FFFFFF}You've just removed your Halloween mask successfully.");
                }

            SetPlayerAttachedObject(playerid, 9, 11704, 2, 0.05, 0.1, 0.0, -5.099, 85.6, -179.4, 0.396, 0.739, 0.422, 0, 0);
            // Resized the original object which was too big by default
            EditAttachedObject(playerid, 9);  
            SendClientMessage(playerid, 0x33CCFFFF, "INFO: {FFFFFF}You've just put on your Halloween mask! You can remove it by retyping the command.");
        }
    }
    return 1;
}
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 31/10/2018, 04:47 PM   #1154
Heress
Huge Clucker
 
Heress's Avatar
 
Join Date: Mar 2018
Location: Lithuania
Posts: 262
Reputation: 7
Default Re: Useful Snippets

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









Respect: Kalcor, ******. Thank you for this great game!
Heress is offline   Reply With Quote
Old 09/11/2018, 08:41 AM   #1155
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
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 01:13 PM.
Riddick94 is offline   Reply With Quote
Old 24/01/2019, 05:05 PM   #1156
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 92
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, 05:15 PM   #1157
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 254
Reputation: 25
Default Re: Useful Snippets

Quote:
Originally Posted by Lokii View Post
HitMarker:
What does?
SymonClash is offline   Reply With Quote
Old 02/02/2019, 05:27 PM   #1158
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 92
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, 05:45 PM   #1159
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 96
Reputation: 35
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, 05:28 AM   #1160
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
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
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 11:22 AM


All times are GMT. The time now is 06:58 PM.


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