SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/02/2015, 12:33 PM   #1011
LivingLikeYouDo
Banned
 
Join Date: Jun 2014
Location: <4char>
Posts: 357
Reputation: 28
Default Re: Useful Snippets

Oh, thanks for the correction! And thanks for the link, too. Helps me alot!
LivingLikeYouDo is offline   Reply With Quote
Old 03/02/2015, 04:07 PM   #1012
Gryphus One
Gangsta
 
Gryphus One's Avatar
 
Join Date: Aug 2010
Location: Griswall, Aurelia
Posts: 553
Reputation: 71
Default Respuesta: Useful Snippets

Wow I didn't know anything about that infinity thing, it's awesome!!
How come this is somewhat "secret" and it's not generally known by anyone with the slightest idea of scripting?
__________________
Quote:
Originally Posted by OTACON View Post
si se hace las cosas bien, no es necesario que se tenga la opción compilar.
compilar es guardar, pero solo que el pawno te dice los errores cometidos.
Quote:
Originally Posted by Fabio_Ganza View Post
Oh and yes, why should I be ashamed? Because of people that are behind their PCs like 24/7, with 120 kilograms up their ass in 15 years of age? Give me a break.
Quote:
Originally Posted by FlawPaw View Post
like he seid my brother tried & he's head esploded hes in hospital i recommend u not to do it
Gryphus One is offline   Reply With Quote
Old 03/02/2015, 04:11 PM   #1013
LivingLikeYouDo
Banned
 
Join Date: Jun 2014
Location: <4char>
Posts: 357
Reputation: 28
Default Re: Respuesta: Useful Snippets

Quote:
Originally Posted by Gryphus One View Post
Wow I didn't know anything about that infinity thing, it's awesome!!
How come this is somewhat "secret" and it's not generally known by anyone with the slightest idea of scripting?
Because mostly new scripters try to use the '1000000' way for infinity, instead of using an original infinity value.
LivingLikeYouDo is offline   Reply With Quote
Old 03/02/2015, 06:11 PM   #1014
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,918
Reputation: 378
Default Re: Useful Snippets

Apart from the health & ammo of player / vehicle, what else could I actually use the infinity & nan value for?
__________________
Luis- is offline   Reply With Quote
Old 03/02/2015, 06:32 PM   #1015
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,918
Reputation: 378
Default Re: Useful Snippets

Ah, fair enough. Thanks!
__________________
Luis- is offline   Reply With Quote
Old 03/02/2015, 11:29 PM   #1016
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 805
Reputation: 155
Default Re: Useful Snippets

CheckValidDate();

Checks for valid months, days and years and also leap years. After searching I couldn't find one that also checked leapyears so here you go.

use like CheckValidDate(15, 03, 1997);

Returns false if non-valid and true if valid.


pawn Code:
stock CheckValidDate(day, month, year)
{
    new Months[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    new bool: leapY;
    switch(year)
    {
        case 1904,1908,1912,1916,1920,1924,
        1928,1932,1936,1940,1944,1948,
        1952,1956,1960,1964,1968,1972,
        1976,1980,1984,1988,1992,1996,
        2000,2004,2008,2012,2016,2020,
        2024,2028,2032,2036,2040,2044,
        2048,2052,2056,2060,2064,2068,
        2072,2076,2080,2084,2088,2092,2096:
        {
            leapY = true;
        }
        default: leapY = false;
    }
    if(month < 1 || month > 12)
        return false;
    else if(!leapY && month == 2 && day >= 29)
        return false;
    else if(day > Months[month])
        return false;
    else if(year < 1900 || year > 2099)
        return false;
    return true;
}
Isolated is offline   Reply With Quote
Old 04/02/2015, 12:29 AM   #1017
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,818
Reputation: 650
Default AW: Re: Useful Snippets

you made a mistake in that line
pawn Code:
else if(day > Months[month]) // should be month -1 because arrays start with 0 not with 1
You could also simplify some things
pawn Code:
stock CheckValidDate(day, month, year) {
    static const
        days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
    ;
    return
        (1582 < year) &&
        (1 <= month <= 12) && (
            (day <= days[month - 1]) ||
            (month == 2 && day == 29 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
        )
    ;
}
Nero_3D is online now   Reply With Quote
Old 04/02/2015, 02:54 PM   #1018
Ada32
Huge Clucker
 
Ada32's Avatar
 
Join Date: Apr 2013
Posts: 293
Reputation: 62
Default Re: Useful Snippets

^ "and you never ever look at it again.."

moral: you're almost always wrong even when you try not to be..
Ada32 is offline   Reply With Quote
Old 14/02/2015, 03:34 PM   #1019
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,835
Reputation: 1607
Default Re: Useful Snippets

All vending machines:
pawn Code:
enum E_VENDING_MACHINE {
          e_Model,
          e_Interior,
    Float:e_PosX,
    Float:e_PosY,
    Float:e_PosZ,
    Float:e_RotX,
    Float:e_RotY,
    Float:e_RotZ,
    Float:e_FrontX,
    Float:e_FrontY
}

stock const Float:g_VendingMachines[][E_VENDING_MACHINE] = {
    {955, 0, -862.82, 1536.60, 21.98, 0.00, 0.00, 180.00, -862.84, 1537.60},
    {956, 0, 2271.72, -76.46, 25.96, 0.00, 0.00, 0.00, 2271.72, -77.46},
    {955, 0, 1277.83, 372.51, 18.95, 0.00, 0.00, 64.00, 1278.73, 372.07},
    {956, 0, 662.42, -552.16, 15.71, 0.00, 0.00, 180.00, 662.41, -551.16},
    {955, 0, 201.01, -107.61, 0.89, 0.00, 0.00, 270.00, 200.01, -107.63},
    {955, 0, -253.74, 2597.95, 62.24, 0.00, 0.00, 90.00, -252.74, 2597.95},
    {956, 0, -253.74, 2599.75, 62.24, 0.00, 0.00, 90.00, -252.74, 2599.75},
    {956, 0, -76.03, 1227.99, 19.12, 0.00, 0.00, 90.00, -75.03, 1227.99},
    {955, 0, -14.70, 1175.35, 18.95, 0.00, 0.00, 180.00, -14.72, 1176.35},
    {1977, 7, 316.87, -140.35, 998.58, 0.00, 0.00, 270.00, 315.87, -140.36},
    {1775, 17, 373.82, -178.14, 1000.73, 0.00, 0.00, 0.00, 373.82, -179.14},
    {1776, 17, 379.03, -178.88, 1000.73, 0.00, 0.00, 270.00, 378.03, -178.90},
    {1775, 17, 495.96, -24.32, 1000.73, 0.00, 0.00, 180.00, 495.95, -23.32},
    {1776, 17, 500.56, -1.36, 1000.73, 0.00, 0.00, 0.00, 500.56, -2.36},
    {1775, 17, 501.82, -1.42, 1000.73, 0.00, 0.00, 0.00, 501.82, -2.42},
    {956, 0, -1455.11, 2591.66, 55.23, 0.00, 0.00, 180.00, -1455.13, 2592.66},
    {955, 0, 2352.17, -1357.15, 23.77, 0.00, 0.00, 90.00, 2353.17, -1357.15},
    {955, 0, 2325.97, -1645.13, 14.21, 0.00, 0.00, 0.00, 2325.97, -1646.13},
    {956, 0, 2139.51, -1161.48, 23.35, 0.00, 0.00, 87.00, 2140.51, -1161.53},
    {956, 0, 2153.23, -1016.14, 62.23, 0.00, 0.00, 127.00, 2154.03, -1015.54},
    {955, 0, 1928.73, -1772.44, 12.94, 0.00, 0.00, 90.00, 1929.73, -1772.44},
    {1776, 1, 2222.36, 1602.64, 1000.06, 0.00, 0.00, 90.00, 2223.36, 1602.64},
    {1775, 1, 2222.20, 1606.77, 1000.05, 0.00, 0.00, 90.00, 2223.20, 1606.77},
    {1775, 1, 2155.90, 1606.77, 1000.05, 0.00, 0.00, 90.00, 2156.90, 1606.77},
    {1775, 1, 2209.90, 1607.19, 1000.05, 0.00, 0.00, 270.00, 2208.90, 1607.17},
    {1776, 1, 2155.84, 1607.87, 1000.06, 0.00, 0.00, 90.00, 2156.84, 1607.87},
    {1776, 1, 2202.45, 1617.00, 1000.06, 0.00, 0.00, 180.00, 2202.43, 1618.00},
    {1776, 1, 2209.24, 1621.21, 1000.06, 0.00, 0.00, 0.00, 2209.24, 1620.21},
    {1776, 3, 330.67, 178.50, 1020.07, 0.00, 0.00, 0.00, 330.67, 177.50},
    {1776, 3, 331.92, 178.50, 1020.07, 0.00, 0.00, 0.00, 331.92, 177.50},
    {1776, 3, 350.90, 206.08, 1008.47, 0.00, 0.00, 90.00, 351.90, 206.08},
    {1776, 3, 361.56, 158.61, 1008.47, 0.00, 0.00, 180.00, 361.54, 159.61},
    {1776, 3, 371.59, 178.45, 1020.07, 0.00, 0.00, 0.00, 371.59, 177.45},
    {1776, 3, 374.89, 188.97, 1008.47, 0.00, 0.00, 0.00, 374.89, 187.97},
    {1775, 2, 2576.70, -1284.43, 1061.09, 0.00, 0.00, 270.00, 2575.70, -1284.44},
    {1775, 15, 2225.20, -1153.42, 1025.90, 0.00, 0.00, 270.00, 2224.20, -1153.43},
    {955, 0, 1154.72, -1460.89, 15.15, 0.00, 0.00, 270.00, 1153.72, -1460.90},
    {956, 0, 2480.85, -1959.27, 12.96, 0.00, 0.00, 180.00, 2480.84, -1958.27},
    {955, 0, 2060.11, -1897.64, 12.92, 0.00, 0.00, 0.00, 2060.11, -1898.64},
    {955, 0, 1729.78, -1943.04, 12.94, 0.00, 0.00, 0.00, 1729.78, -1944.04},
    {956, 0, 1634.10, -2237.53, 12.89, 0.00, 0.00, 0.00, 1634.10, -2238.53},
    {955, 0, 1789.21, -1369.26, 15.16, 0.00, 0.00, 270.00, 1788.21, -1369.28},
    {956, 0, -2229.18, 286.41, 34.70, 0.00, 0.00, 180.00, -2229.20, 287.41},
    {955, 256, -1980.78, 142.66, 27.07, 0.00, 0.00, 270.00, -1981.78, 142.64},
    {955, 256, -2118.96, -423.64, 34.72, 0.00, 0.00, 255.00, -2119.93, -423.40},
    {955, 256, -2118.61, -422.41, 34.72, 0.00, 0.00, 255.00, -2119.58, -422.17},
    {955, 256, -2097.27, -398.33, 34.72, 0.00, 0.00, 180.00, -2097.29, -397.33},
    {955, 256, -2092.08, -490.05, 34.72, 0.00, 0.00, 0.00, -2092.08, -491.05},
    {955, 256, -2063.27, -490.05, 34.72, 0.00, 0.00, 0.00, -2063.27, -491.05},
    {955, 256, -2005.64, -490.05, 34.72, 0.00, 0.00, 0.00, -2005.64, -491.05},
    {955, 256, -2034.46, -490.05, 34.72, 0.00, 0.00, 0.00, -2034.46, -491.05},
    {955, 256, -2068.56, -398.33, 34.72, 0.00, 0.00, 180.00, -2068.58, -397.33},
    {955, 256, -2039.85, -398.33, 34.72, 0.00, 0.00, 180.00, -2039.86, -397.33},
    {955, 256, -2011.14, -398.33, 34.72, 0.00, 0.00, 180.00, -2011.15, -397.33},
    {955, 2048, -1350.11, 492.28, 10.58, 0.00, 0.00, 90.00, -1349.11, 492.28},
    {956, 2048, -1350.11, 493.85, 10.58, 0.00, 0.00, 90.00, -1349.11, 493.85},
    {955, 0, 2319.99, 2532.85, 10.21, 0.00, 0.00, 0.00, 2319.99, 2531.85},
    {956, 0, 2845.72, 1295.04, 10.78, 0.00, 0.00, 0.00, 2845.72, 1294.04},
    {955, 0, 2503.14, 1243.69, 10.21, 0.00, 0.00, 180.00, 2503.12, 1244.69},
    {956, 0, 2647.69, 1129.66, 10.21, 0.00, 0.00, 0.00, 2647.69, 1128.66},
    {1209, 0, -2420.21, 984.57, 44.29, 0.00, 0.00, 90.00, -2419.21, 984.57},
    {1302, 0, -2420.17, 985.94, 44.29, 0.00, 0.00, 90.00, -2419.17, 985.94},
    {955, 0, 2085.77, 2071.35, 10.45, 0.00, 0.00, 90.00, 2086.77, 2071.35},
    {956, 0, 1398.84, 2222.60, 10.42, 0.00, 0.00, 180.00, 1398.82, 2223.60},
    {956, 0, 1659.46, 1722.85, 10.21, 0.00, 0.00, 0.00, 1659.46, 1721.85},
    {955, 0, 1520.14, 1055.26, 10.00, 0.00, 0.00, 270.00, 1519.14, 1055.24},
    {1775, 6, -19.03, -57.83, 1003.63, 0.00, 0.00, 180.00, -19.05, -56.83},
    {1775, 18, -16.11, -91.64, 1003.63, 0.00, 0.00, 180.00, -16.13, -90.64},
    {1775, 16, -15.10, -140.22, 1003.63, 0.00, 0.00, 180.00, -15.11, -139.22},
    {1775, 17, -32.44, -186.69, 1003.63, 0.00, 0.00, 180.00, -32.46, -185.69},
    {1775, 16, -35.72, -140.22, 1003.63, 0.00, 0.00, 180.00, -35.74, -139.22},
    {1776, 6, -36.14, -57.87, 1003.63, 0.00, 0.00, 180.00, -36.16, -56.87},
    {1776, 18, -17.54, -91.71, 1003.63, 0.00, 0.00, 180.00, -17.56, -90.71},
    {1776, 16, -16.53, -140.29, 1003.63, 0.00, 0.00, 180.00, -16.54, -139.29},
    {1776, 17, -33.87, -186.76, 1003.63, 0.00, 0.00, 180.00, -33.89, -185.76},
    {1775, 6, -19.03, -57.83, 1003.63, 0.00, 0.00, 180.00, -19.05, -56.83},
    {1776, 6, -36.14, -57.87, 1003.63, 0.00, 0.00, 180.00, -36.16, -56.87},
    {1775, 18, -16.11, -91.64, 1003.63, 0.00, 0.00, 180.00, -16.13, -90.64},
    {1776, 18, -17.54, -91.71, 1003.63, 0.00, 0.00, 180.00, -17.56, -90.71},
    {1776, 16, -16.53, -140.29, 1003.63, 0.00, 0.00, 180.00, -16.54, -139.29},
    {1775, 16, -15.10, -140.22, 1003.63, 0.00, 0.00, 180.00, -15.11, -139.22},
    {1776, 17, -33.87, -186.76, 1003.63, 0.00, 0.00, 180.00, -33.89, -185.76},
    {1775, 17, -32.44, -186.69, 1003.63, 0.00, 0.00, 180.00, -32.46, -185.69},
    {1775, 16, -35.72, -140.22, 1003.63, 0.00, 0.00, 180.00, -35.74, -139.22}
};
Slice is offline   Reply With Quote
Old 16/02/2015, 01:45 AM   #1020
Hanger
Big Clucker
 
Join Date: Apr 2012
Location: UK
Posts: 161
Reputation: 32
Default Re: Useful Snippets

http://pastebin.com/G9X6qUG6

Created this quite a while back and since I have not touched samp decided to contribute to the community by sharing some of my GTA patching ideas.

It is nothing big, a simple server sided weapons AND ammunition which allows the use of built-in weapon shops, safe use of weapon pick-ups.

There is one callback which is called when a player uses in game weapon shop, don't know how useful this is for some.
Code:
// return 0 to prevent the purchase
forward OnPlayerPurchaseWeapon(playerid, weaponid, totalammo);
As far as I can remember this include functioned perfectly with all sorts of weapons including grenades, tear gas, parachutes etc - but if not, you know this is a snippet!

There is a minor issue, fast rated weapons such as MP5 and minigun can cause some game bugs to appear.
Also weapons gained from vehicles such as police cars will not be saved for the player, but this can be done if you have time and power.

You can use this as p&p include after y_* and use normal GetPlayerWeapon etc in your scripts, avoid related filterscripts.

some of the callback code might be outdated so please be aware, feel free to recreate this.
__________________
Hanger 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 04:51 PM.


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