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 |
new str[10 char] = !"Thug life";
#define if while
#define break continue
#define string.clear(%0) \
%0[0] = EOS
//or
#define string.clear(%0) \
%0[0] = '\0'
#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;
}
Before: Hello, SA-MP Forums. | 72 | Not Null After: | 0 | Null
#define clear.%0() (%0[0] = '\0')
clear.str[0/*0 .. 128 and so on*/]();
//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.
PlayerDaysAliveTimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);//this is timer.
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.
}
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:
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:
Now Add This In The Center Of You Script. PHP Code:
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. |
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,
}
#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);
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;
}
#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;
}
An enumerator flag of all SA-MP callbacks of 0.3z and an array list of their names.
|
#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)
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;
}
anti eagle drive by
pawn Код:
|
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; }
new Float:x,Float:y; modf(14.23,x,y); printf("Result X = %f\nResult Y = %f",x,y);
Result X = 14.0 Result Y = 0.23
enum e_Interiors {
iInt,
Float:iX,
Float:iY,
Float:iZ
};
new g_InteriorInfo[13][e_Interiors] = {
{1, 2207.6660, -1075.4729, 1050.4844}, /* The Camel's Toe, The Clown's Pocket */
{2, 2237.4875, -1076.0233, 1049.0234}, /* Old Venturas Strip, The Pirates in Men's Pants */
{3, 2495.5078, -1700.7537, 1014.7422}, /* Grove Street */
{5, 1300.1019, -790.3085, 1084.0078}, /* Mulholland (Madd Dogg's Mansion) */
{5, 2233.3081, -1109.3021, 1050.8828}, /* Hotel Vank Hoff in the Park */
{6, 2193.2417, -1202.6016, 1049.0234}, /* Mulholland, Doherty, Calton Heights, */
{6, 2334.1479, -1064.9392, 1049.0234}, /* Blueberry, Dillimore, Palomino Creek, Angel Pine, Whetstone, El Quebrados, Tierra Robada, Fort Carson */
{6, 2312.9792, -1209.4229, 1049.0234}, /* Creek, Chinatown, Paradiso */
{8, 2365.2576, -1130.4613, 1050.8750}, /* Redsands West, Rockshore West, Whitewood Estates, Verdant Bluffs, Verona Beach, Santa Maria Beach */
{9, 2319.5112, -1024.4088, 1050.2109}, /* Prickle Pine */
{10, 2256.4766, -1209.6136, 1049.0234}, /* Hashbury */
{10, 418.5927, 2537.2952, 10.0000}, /* Verdant Meadows */
{11, 2283.1919, -1137.0828, 1050.8984} /* Jefferson, Willowfield */
};
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;
}
public OnPlayerText(playerid, text[]) { if(strfind(text, "hacker", true) != -1) { SendClientMessage(playerid, -1, "Use /report to report hackers!"); return 0; } return 1; }
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} };