Useful Snippets

Quote:
Originally Posted by Slice
Посмотреть сообщение
You didn't fail miserably, you just mixed a few things up! It happens.

You also helped finding a new way of making pointers, which is much faster compared to the previous version!

http://forum.sa-mp.com/showthread.ph...49#post2738949
Usually, the ! before a string indicates that it's packed, like so:

pawn Код:
new str[10 char] = !"Thug life";
And I also didn't know that! I was just finding out how to effectively utilize the packed arrays so I don't end up using a huge amount of cells for something small.
Reply

Hardcore mode
pawn Код:
#define if while
#define break continue
sorry
Reply

string.clear, C++ string.clear function into sa-mp

Macro/Code
pawn Код:
#define string.clear(%0) \
    %0[0] = EOS

//or

#define string.clear(%0) \
    %0[0] = '\0'
Example Code
pawn Код:
#include <a_samp>

#define string.clear(%0) \
    %0[0] = EOS

#define isnull(%1) \
            ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))

new string[21] = "Hello, SA-MP Forums.";

main()
{
    SetTimer("ClearString", 2000, false);
    if(isnull( string ) )
    {
        return printf("Before: %s | = %i | Not Null", string, string);
    }
    return true;
}

forward ClearString();
public ClearString()
{
    string.clear(string);
    if(isnull( string ) )
    {
        return printf("After: %s | = %i | Null", string, string);
    }
    return true;
}
Result
Код:
Before: Hello, SA-MP Forums. | 72 | Not Null
After:  | 0 | Null
Have a nice day!

EDIT: Thanks to Konstantinos for his Smart Idea

pawn Код:
#define clear.%0() (%0[0] = '\0')
Usage
Код:
 clear.str[0/*0 .. 128 and so on*/]();
Reply

Hello, Guyz This is My First Tutorial, and Im Going to Teach You How To Make a Simple Birthday System
And Sorry For My Bad English.
lets Start.

First Put This On The Top Of Your Script.

PHP Code:
//This is Just an Exapmle Seconds and Its Not Saving. im just giving an Example.
new PlayerDaysAliveTimer[MAX_PLAYERS];//Timer Variable.
new Seconds[MAX_PLAYERS];
new 
Minutes[MAX_PLAYERS];
new 
Hours[MAX_PLAYERS];
new 
Days[MAX_PLAYERS];
new 
Years[MAX_PLAYERS];
new 
BirthdayCount[MAX_PLAYERS];//we will use this with Player Days, B/c When Player Days Reached At 365 And Birthday Count to 365 Server Will Reset Birthday Count = 0; and Start it again for next year count. and days will be countinued and will not get reseted. 
Here We will Make Timer. Which Will Count Seconds. we can use this Under OnPlayerConnect. And Also You can Use This In You Gamemode/Filterscript. when player login.

Ok Lets Start Timer.

PHP Code:
PlayerDaysAliveTimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);//this is timer. 
Now Add This In The Center Of You Script.


PHP Code:
forward TimeOnServer(playerid);
public 
TimeOnServer(playerid)
{
    for(new 
i;i<MAX_PLAYERS;i++)
    {
    if(
IsPlayerConnected(i))
    {
    
Seconds[playerid]++;//here seonds will be counted.
    
}
    }
if(
Seconds[playerid] >= 60//here if seconds more than \'60\' minuts will be +++ And Seconds will be reseted for next minute count
{
Minutes[playerid]++;//minutes plus.
Seconds[playerid] =0;//seconds reset
}
if(
Minutes[playerid] >=60)//here if minutes played more than 60. hours will be +++
{
Hours[playerid]++;//hours
Minutes[playerid]=0;//minutes to \'0\'
}
if(
Hours[playerid] >=24)//here a day will be counted.
{
Hours[playerid] =0;//hours
Days[playerid]++;//counting days
BirthdayCount[playerid]++;//counting days for birthday. with days.
}
if(
BirthdayCount[playerid] >= 365)//here birthday count will be counted with days b/c days will be continue to next birthday like 365 to 720. for new birthday.
{
//Do You Stuff, Here Which u want.
Years[playerid]++;//counting players years alive.

Thank You.

Danish.

This Is My First Tutorial. and I Hope It will be Usefull For You. Birthday is very common and it is used in most of roleplay/and cnr servers.
+REP If it Helped You.
Reply

Quote:
Originally Posted by danish007
View Post
Hello, Guyz This is My First Tutorial, and Im Going to Teach You How To Make a Simple Birthday System
And Sorry For My Bad English.
lets Start.

First Put This On The Top Of Your Script.

PHP Code:
//This is Just an Exapmle Seconds and Its Not Saving. im just giving an Example.
new PlayerDaysAliveTimer[MAX_PLAYERS];//Timer Variable.
new Seconds[MAX_PLAYERS];
new 
Minutes[MAX_PLAYERS];
new 
Hours[MAX_PLAYERS];
new 
Days[MAX_PLAYERS];
new 
Years[MAX_PLAYERS];
new 
BirthdayCount[MAX_PLAYERS];//we will use this with Player Days, B/c When Player Days Reached At 365 And Birthday Count to 365 Server Will Reset Birthday Count = 0; and Start it again for next year count. and days will be countinued and will not get reseted. 
Here We will Make Timer. Which Will Count Seconds. we can use this Under OnPlayerConnect. And Also You can Use This In You Gamemode/Filterscript. when player login.

Ok Lets Start Timer.

PHP Code:
PlayerDaysAliveTimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);//this is timer. 
Now Add This In The Center Of You Script.


PHP Code:
forward TimeOnServer(playerid);
public 
TimeOnServer(playerid)
{
    for(new 
i;i<MAX_PLAYERS;i++)
    {
    if(
IsPlayerConnected(i))
    {
    
Seconds[playerid]++;//here seonds will be counted.
    
}
    }
if(
Seconds[playerid] >= 60//here if seconds more than \'60\' minuts will be +++ And Seconds will be reseted for next minute count
{
Minutes[playerid]++;//minutes plus.
Seconds[playerid] =0;//seconds reset
}
if(
Minutes[playerid] >=60)//here if minutes played more than 60. hours will be +++
{
Hours[playerid]++;//hours
Minutes[playerid]=0;//minutes to \'0\'
}
if(
Hours[playerid] >=24)//here a day will be counted.
{
Hours[playerid] =0;//hours
Days[playerid]++;//counting days
BirthdayCount[playerid]++;//counting days for birthday. with days.
}
if(
BirthdayCount[playerid] >= 365)//here birthday count will be counted with days b/c days will be continue to next birthday like 365 to 720. for new birthday.
{
//Do You Stuff, Here Which u want.
Years[playerid]++;//counting players years alive.

Thank You.

Danish.

This Is My First Tutorial. and I Hope It will be Usefull For You. Birthday is very common and it is used in most of roleplay/and cnr servers.
+REP If it Helped You.
wow u made a simple code too hard my code is pretty small from your code...just 2 variables 1 for days and for birthdays
Reply

An enumerator flag of all SA-MP callbacks of 0.3z and an array list of their names.
pawn Код:
new
    e_CBNames[][] = {
    {"OnDialogResponse"},
    {"OnEnterExitModShop"},
    {"OnFilterScriptInit"},
    {"OnFilterScriptExit"},
    {"OnGameModeInit"},
    {"OnGameModeExit"},
    {"OnIncomingConnection"},
    {"OnObjectMoved"},
    {"OnPlayerClickMap"},
    {"OnPlayerClickPlayer"},
    {"OnPlayerClickPlayerTextDraw"},
    {"OnPlayerClickTextDraw"},
    {"OnPlayerCommandText"},
    {"OnPlayerConnect"},
    {"OnPlayerDeath"},
    {"OnPlayerDisconnect"},
    {"OnPlayerEditAttachedObject"},
    {"OnPlayerEditObject"},
    {"OnPlayerEnterCheckpoint"},
    {"OnPlayerEnterRaceCheckpoint"},
    {"OnPlayerEnterVehicle"},
    {"OnPlayerExitVehicle"},
    {"OnPlayerExitedMenu"},
    {"OnPlayerGiveDamage"},
    {"OnPlayerInteriorChange"},
    {"OnPlayerKeyStateChange"},
    {"OnPlayerLeaveCheckpoint"},
    {"OnPlayerLeaveRaceCheckpoint"},
    {"OnPlayerObjectMoved"},
    {"OnPlayerPickUpPickup"},
    {"OnPlayerRequestClass"},
    {"OnPlayerRequestSpawn"},
    {"OnPlayerSelectObject"},
   
    {"OnPlayerSelectedMenuRow"},
    {"OnPlayerSpawn"},
    {"OnPlayerStateChange"},
    {"OnPlayerStreamIn"},
    {"OnPlayerStreamOut"},
    {"OnPlayerTakeDamage"},
    {"OnPlayerText"},
    {"OnPlayerUpdate"},
    {"OnPlayerWeaponShot"},
    {"OnRconCommand"},
    {"OnRconLoginAttempt"},
    {"OnTrailerUpdate"},
    {"OnUnoccupiedVehicleUpdate"},
    {"OnVehicleDamageStatusUpdate"},
    {"OnVehicleDeath"},
    {"OnVehicleMod"},
    {"OnVehiclePaintjob"},
    {"OnVehicleRespray"},
    {"OnVehicleSpawn"},
    {"OnVehicleStreamIn"},
    {"OnVehicleStreamOut"}
};


enum e_Callback_Flags_1:(<<= 1) {

    e_FLAG_OnDialogResponse = 1,
    e_FLAG_OnEnterExitModShop,
    e_FLAG_OnFilterScriptInit,
    e_FLAG_OnFilterScriptExit,
    e_FLAG_OnGameModeInit,
    e_FLAG_OnGameModeExit,
    e_FLAG_OnIncomingConnection,
    e_FLAG_OnObjectMoved,
    e_FLAG_OnPlayerClickMap,
    e_FLAG_OnPlayerClickPlayer,
    e_FLAG_OnPlayerClickPTXD,
    e_FLAG_OnPlayerClickTXD,
    e_FLAG_OnPlayerCMDText,
    e_FLAG_OnPlayerConnect,
    e_FLAG_OnPlayerDeath,
    e_FLAG_OnPlayerDisconnect,
    e_FLAG_OnPlayerEAObj,
    e_FLAG_OnPlayerEObj,
    e_FLAG_OnPlayerECp,
    e_FLAG_OnPlayerERCp,
    e_FLAG_OnPlayerEVeh,
    e_FLAG_OnPlayerExVeh,
    e_FLAG_OnPlayerExMenu,
    e_FLAG_OnPlayerGDamage,
    e_FLAG_OnPlayerIntChange,
    e_FLAG_OnPlayerKeyChange,
    e_FLAG_OnPlayerLeaveCp,
    e_FLAG_OnPlayerLeaveRCp,
    e_FLAG_OnPlayerObjMoved,
    e_FLAG_OnPlayerPickupP,
    e_FLAG_OnPlayerReqClass,
    e_FLAG_OnPlayerReqSpawn,
    e_FLAG_OnPlayerSObj
}





enum e_Callback_Flags_2:(<<= 1) {

    e_FLAG_OnPlayerSMenuRow = 1,
    e_FLAG_OnPlayerSpawn,
    e_FLAG_OnPlayerStateChange,
    e_FLAG_OnPlayerStreamIn,
    e_FLAG_OnPlayerStreamOut,
    e_FLAG_OnPlayerTDamage,
    e_FLAG_OnPlayerText,
    e_FLAG_OnPlayerUpdate,
    e_FLAG_OnPlayerWepShot,
    e_FLAG_OnRconCommand,
    e_FLAG_OnRconLoginAt,
    e_FLAG_OnTrailerUpdate,
    e_FLAG_OnUnVehUpdate,
    e_FLAG_OnVDmgUpdate,
    e_FLAG_OnVehicleDeath,
    e_FLAG_OnVehicleMod,
    e_FLAG_OnVehiclePJob,
    e_FLAG_OnVehicleRespray,
    e_FLAG_OnVehicleSpawn,
    e_FLAG_OnVehicleStrIn,
    e_FLAG_OnVehicleStrOut,
}
Reply

@fall3n - Thanks for this! I was working on this too, but I guess late
This is really useful. Thanks again.
Reply

I guess I'll just post this here since it's kinda small:

pawn Код:
#include <a_samp>
#tryinclude <YSI\y_hook>

#if !defined hook
    #define hook public
#endif
hook OnPlayerDeath(playerid, killerid, reason)
{
    if(reason == WEAPON_DROWN)
    {
        if(killerid == playerid || killerid == INVALID_PLAYER_ID)
        {
            new Float: X, Float: Y, Float: Z, Float: fAngle;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid, fAngle);
            CallLocalFunction("OnPlayerDrown", "iffff", playerid, X, Y, Z, fAngle);
            return 1;
        }
    }
    return true;
}

forward OnPlayerDrown(playerid, Float: dX, Float: dY, Float: dZ, Float: dAngle);
Basically gets called when a player drowns. It will also give the coordinates, along with the facing angle of the player when they died / drowned. You can prevent hacks / exploits I imagine by checking if it's in range of a body of water, etc.
Reply

anti eagle drive by
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) {
    if(weaponid == 24 && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) {
        SetPlayerArmedWeapon(playerid, 0);
        return 0; // desync the shot
    }
    return 1;
}
Reply

OnPlayerChainKill

This callback is called whenever a player gains multiple kills in the given time, basically forming a kill chain.

Parameters:
playerid - The player who does the kill chain.
deadid - The last player who killed by the player while achieving kill chain.
reason - The reason/weaponid used for kill.
chaincounts - The value of player's total chaincounts processed on this callback. It automatically gets reset if player doesn't achieve another kill in given time.

Code:
pawn Код:
#define KILL_CHAIN_TIME     10000 //10 seconds, the given time. Reduce or increase it according to your wish.

new
    g_PlayerLastKillTime[MAX_PLAYERS] = {0, ...},
    g_PlayerChainCount[MAX_PLAYERS] = {0, ...};

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID && killerid != playerid)
    {
        if((GetTickCount() - g_PlayerLastKillTime[killerid]) <= KILL_CHAIN_TIME)
        {
            g_PlayerChainCount[killerid]++;
            CallLocalFunction("OnPlayerChainKill", "iiii", killerid, playerid, reason, g_PlayerChainCount[killerid]);
        }
        else g_PlayerChainCount[killerid] = 0;
    }
    g_PlayerLastKillTime[killerid] = GetTickCount();
    return 1;
}

forward OnPlayerChainKill(playerid, deadid, reason, chaincount);

public OnPlayerChainKill(playerid, deadid, reason, chaincount)
{
//  printf("Chain count : %d", chaincount); //debug
    return 1;
}
Reply

Quote:
Originally Posted by fall3n
Посмотреть сообщение
An enumerator flag of all SA-MP callbacks of 0.3z and an array list of their names.
What is this for?
Reply

Anti money cheat and vending machine detector.
requires fixes2 plugin and y_hooks
pawn Код:
#define Public::%1(%2) forward %1(%2); \
                        public %1(%2)

#define GiveCash(%0,%1) Player[%0][Cash] += %1, GivePlayerMoney(%0, %1)
#define SetCash(%0,%1) Player[%0][Cash] = %1, ResetPlayerMoney(%0), GivePlayerMoney(%0, %1)
#define ResetCash(%0) Player[%0][Cash] = 0, ResetPlayerMoney(%0)
pawn Код:
Public::AntiSystem(playerid)
{
    new gtaMoney = GetPlayerMoney(playerid);
    if(gtaMoney != Player[playerid][Cash])
    {
        //do something ere
    }
    return 1;
}

hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK, newkeys, oldkeys)) {
        if(GetPlayerAnimationIndex(playerid) != 1660)
        {
            if(IsPlayerNearVending(playerid))
            {
                SetTimerEx_("ValidateVending", 100, 500, 1, "d", playerid);
            }
        }
    }
    return 1;
}

Public::ValidateVending(playerid)
{
    if(GetPlayerAnimationIndex(playerid) == 1660)
    {
        SetCash(playerid, Player[playerid][Cash]);
        GiveCash(playerid, -1);
    }
}


new Float:VendingSpots[][3] = {
    {-14.70, 1175.36, 18.95},
    {201.02, -107.62, 0.90},
    {662.43, -552.16, 15.71},
    {-76.03, 1227.99, 19.13},
    {1154.73, -1460.89, 15.16},
    {1277.84, 372.52, 18.95},
    {1398.84, 2222.61, 10.42},
    {1520.15, 1055.27, 10.00},
    {1634.11, -2237.53, 12.89},
    {1659.46, 1722.86, 10.22},
    {1729.79, -1943.05, 12.95},
    {1789.21, -1369.27, 15.16},
    {1928.73, -1772.45, 12.95},
    {2060.12, -1897.64, 12.93},
    {2085.77, 2071.36, 10.45},
    {2139.52, -1161.48, 23.36},
    {2153.23, -1016.15, 62.23},
    {2271.73, -76.46, 25.96},
    {2319.99, 2532.85, 10.22},
    {2325.98, -1645.13, 14.21},
    {2352.18, -1357.16, 23.77},
    {2480.86, -1959.27, 12.96},
    {2503.14, 1243.70, 10.22},
    {-253.74, 2597.95, 62.24},
    {-253.74, 2599.76, 62.24},
    {2647.70, 1129.66, 10.22},
    {2845.73, 1295.05, 10.79},
    {-862.83, 1536.61, 21.98},
    {-1350.12, 492.29, 10.59},
    {-1350.12, 493.86, 10.59},
    {-1455.12, 2591.66, 55.23},
    {-1980.79, 142.66, 27.07},
    {-2005.65, -490.05, 34.73},
    {-2011.14, -398.34, 34.73},
    {-2034.46, -490.05, 34.73},
    {-2039.85, -398.34, 34.73},
    {-2063.27, -490.05, 34.73},
    {-2068.56, -398.34, 34.73},
    {-2092.09, -490.05, 34.73},
    {-2097.27, -398.34, 34.73},
    {-2118.62, -422.41, 34.73},
    {-2118.97,-423.65, 34.73},
    {-2229.19, 286.41, 34.70},
    {-2420.18, 985.95, 44.30},
    {-2420.22, 984.58, 44.30},
    {2155.84, 1607.88, 1000.06},
    {2155.91, 1606.77, 1000.05},
    {2202.45, 1617.01, 1000.06},
    {2209.24, 1621.21, 1000.06},
    {2209.91, 1607.20, 1000.05},
    {2222.20, 1606.77, 1000.05},
    {2222.37, 1602.64, 1000.06},
    {2225.20, -1153.42, 1025.91},
    {-15.10, -140.23, 1003.63},
    {-16.12, -91.64, 1003.63},
    {-16.53, -140.30, 1003.63},
    {-17.55, -91.71, 1003.63},
    {-19.04, -57.84, 1003.63},
    {-32.45, -186.70, 1003.63},
    {-33.88, -186.77, 1003.63},
    {330.68, 178.50, 1020.07},
    {331.92, 178.50, 1020.07},
    {-35.73, 140.23, 1003.63},
    {350.91, 206.09, 1008.48},
    {-36.15, -57.88, 1003.63},
    {361.56, 158.62, 1008.48},
    {371.59, 178.45, 1020.07},
    {373.83, -178.14, 1000.73},
    {374.89, 188.98, 1008.48},
    {379.04, -178.88, 1000.73},
    {495.97, -24.32, 1000.73},
    {500.56, -1.37, 1000.73},
    {501.83, -1.43, 1000.73},
    {2576.70, -1284.43, 1061.09}
};

stock IsPlayerNearVending(playerid)
{
    for (new i = 0; i < sizeof(VendingSpots); i ++)
    {
        if (GetPlayerDistanceFromPoint(playerid, VendingSpots[i][0], VendingSpots[i][1], VendingSpots[i][2]) >= 3.0)
            continue;
        else
            return i;
    }
    return 0;
}

stock IsKeyJustDown(key, newkeys, oldkeys)
{
    if((newkeys & key) && !(oldkeys & key))
        return 1;
    return 0;
}
Reply

Quote:
Originally Posted by Skream
Посмотреть сообщение
anti eagle drive by
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) {
    if(weaponid == 24 && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) {
        SetPlayerArmedWeapon(playerid, 0);
        return 0; // desync the shot
    }
    return 1;
}
really?
Reply

MODF


Introduction

Separates integral part from the fractional part.


Source Code

Код:
stock modf(Float:val1,&Float:val2,&Float:val3)
{
	new str[16],str1[16],str2[16];
	new str3[16],str4[16];
	new c=0,Float:d=1;
	format(str,sizeof(str),"%f",val1);
	for(new i=0;i<strlen(str);i++)
	{
	    if(str[i] != '.')
		{
			format(str1,sizeof(str1),"%c",str[i]);
			strcat(str2,str1);
			c=c+1;
		}
	    else
	    {
	        for(new j=c+1;j<strlen(str);j++)
			{
				format(str3,sizeof(str3),"%c",str[j]);
				strcat(str4,str3);
				d=d*10;
			}
			break;
		}
	}
	
	if(val1<0)
	{
		val2=strval(str2);
		val3=strval(str4)/d*-1.0;
	}
	else
	{
		val2=strval(str2);
		val3=strval(str4)/d;
	}
	
	str[0]='\0';
	str1[0]='\0';
	str2[0]='\0';
	str3[0]='\0';
	str4[0]='\0';
	return 1;
}
Example Code

Код:
new Float:x,Float:y;
modf(14.23,x,y);
printf("Result X = %f\nResult Y = %f",x,y);
Output:
Код:
Result X = 14.0
Result Y = 0.23
Reply

[HLF]Southclaw: Firstly, I posted it in the wrong section by mistake and I am sorry for that. Secondly, I usually try not to use natives as because calling functions from script is a fast method to me.
Reply

-----
Reply

Hello, I made a house system and I extracted all these coordinates which are from the single player safehouses. So, you're free to use them if you need. Many safehouses share the same interior.
PHP код:
enum e_Interiors {
    
iInt,
    
Float:iX,
    
Float:iY,
    
Float:iZ
};
new 
g_InteriorInfo[13][e_Interiors] = {
    {
12207.6660, -1075.47291050.4844},     /* The Camel's Toe, The Clown's Pocket */
    
{22237.4875, -1076.02331049.0234},     /* Old Venturas Strip, The Pirates in Men's Pants */
    
{32495.5078, -1700.75371014.7422},     /* Grove Street */
    
{51300.1019, -790.30851084.0078},   /* Mulholland (Madd Dogg's Mansion) */
    
{52233.3081, -1109.30211050.8828},  /* Hotel Vank Hoff in the Park */
    
{62193.2417, -1202.60161049.0234},  /* Mulholland, Doherty, Calton Heights, */
    
{62334.1479, -1064.93921049.0234},  /* Blueberry, Dillimore, Palomino Creek, Angel Pine, Whetstone, El Quebrados, Tierra Robada, Fort Carson */
    
{62312.9792, -1209.42291049.0234},     /* Creek, Chinatown, Paradiso */
    
{82365.2576, -1130.46131050.8750},     /* Redsands West, Rockshore West, Whitewood Estates, Verdant Bluffs, Verona Beach, Santa Maria Beach */
    
{92319.5112, -1024.40881050.2109},     /* Prickle Pine */
    
{102256.4766, -1209.61361049.0234}, /* Hashbury */
    
{10418.59272537.295210.0000},     /* Verdant Meadows */
    
{112283.1919, -1137.08281050.8984}     /* Jefferson, Willowfield */
}; 
PD: The Four Dragons Casino and save points aren't included, only houses.

http://gta.wikia.com/wiki/Save_Point...TA_San_Andreas
Reply

Are you tired of spawning at the same place many times? This is a snippet of my way to tackle down this problem. Might be useful for other people.

pawn Код:
new Float:SFSpawn[][] =
{
//      X           Y         Z        Angle - SF Spawn
    {   -1935.0742, 678.1586, 46.5625, 356.4240     },
    {   -1922.5177, 680.0504, 46.5625, 2.6907       },
    {   -1934.6843, 264.8631, 41.0469, 276.9846     },
    {   -2022.3842, 155.8002, 28.8359, 266.6432     },
    {   -2314.1555, -169.0953, 35.3203, 178.2457    },
    {   -2126.3633, -383.9755, 35.3359, 2.5950      },
    {   -2720.4807, -317.9581, 7.8438, 41.5845      },
    {   -2521.2214, -621.2564, 132.7300, 1.2376     },
    {   -1928.7382, -790.2328, 32.1506, 273.2949    },
    {   -1953.3707, 1339.3734, 7.1875, 174.4267     }
},
playerLastSpawnID[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    findNewSpawn:
        new randomiseSpawn = random(sizeof(SFSpawn));

    if(playerLastSpawnID[playerid] == randomiseSpawn)
    {
        SendClientMessage(playerid, -1, "fiding new spawn");
        goto findNewSpawn;
        return 1;
    }

    SetPlayerPos(playerid, SFSpawn[randomiseSpawn][0], SFSpawn[randomiseSpawn][1], SFSpawn[randomiseSpawn][2]);
    SetPlayerFacingAngle(playerid, SFSpawn[randomiseSpawn][3]);
    SetCameraBehindPlayer(playerid);

    playerLastSpawnID[playerid] = randomiseSpawn;
    return 1;
}
Reply

Detect "Hacker" word in chat

This system will just detect if player has typed "hacker", then it will block his message and tell him to use /report to report hackers.

Код:
public OnPlayerText(playerid, text[])
{
	if(strfind(text, "hacker", true) != -1)
	{
		SendClientMessage(playerid, -1, "Use /report to report hackers!");
		return 0;
	}
	return 1;
}
Reply

Fire hydrant coords, taken from IPL files. I needed them for a firefighting script.

Код:
new Float: HydrantCoords[46][3] = {
	{-2089.2109, 1258.6953, 13.8047},
	{-2210.7500, 1258.6953, 34.7109},
	{-2282.8750, 952.8516, 65.8672},
	{-2283.6797, 573.9766, 34.7266},
	{-2283.6797, 662.5781, 48.4531},
	{-2283.6797, 802.8984, 48.9766},
	{-2361.6172, 1323.4922, 14.4453},
	{-2370.5781, 573.9766, 24.4766},
	{-2370.5781, 662.5781, 34.7422},
	{-2370.5781, 798.8359, 35.1016},
	{-2370.5781, 952.8125, 45.0781},
	{-2414.8750, 573.9609, 24.4844},
	{-2414.8750, 699.0781, 34.7266},
	{-2414.8750, 813.8047, 34.7734},
	{-2415.5469, 902.4844, 45.1328},
	{-2461.6484, 1323.4922, 12.2969},
	{-2477.6875, 1215.1406, 34.7734},
	{-2501.7656, 573.8281, 14.1641},
	{-2501.7656, 699.0781, 31.1641},
	{-2501.7656, 813.7188, 44.0469},
	{-2501.7656, 913.8984, 64.3750},
	{-2569.3750, 713.7734, 27.4688},
	{-2583.0156, 813.6953, 49.5625},
	{-2593.1172, 573.8203, 14.1484},
	{-2599.3203, 1343.5547, 6.8047},
	{-2634.5625, 899.6016, 70.6406},
	{-2634.5625, 998.9219, 72.2031},
	{-2656.2734, 713.5781, 27.5156},
	{-2669.9062, 817.6953, 49.5234},
	{-2680.0156, 573.8594, 14.1562},
	{-2721.4609, 892.9531, 71.6953},
	{-2721.4609, 998.7422, 54.3203},
	{1266.0859, -906.7031, 42.3984},
	{1289.1406, -938.1250, 40.7734},
	{2495.2656, -1653.6719, 12.9141},
	{2505.6641, -1657.9375, 12.9219},
	{317.8359, -1609.5781, 32.9141},
	{374.6406, -1576.8516, 30.8906},
	{438.8359, -1608.6094, 25.2734},
	{456.3438, -1301.5781, 14.6797},
	{457.2500, -1300.8906, 14.6797},
	{544.3984, -1440.2109, 15.2891},
	{546.0156, -1494.7109, 13.8984},
	{546.5625, -1547.2188, 15.1016},
	{555.1562, -1251.9297, 16.6406},
	{592.8984, -1212.2812, 17.6484}
};
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)