stock GetVehicleType(model)
{
if(model < 400 || model > 611) return 0;
switch(model)
{
case 472, 473, 493, 595, 484, 430, 453, 452, 446: return 1; // Water
case 417, 425, 447, 460, 469, 476, 487, 488, 497, 511, 512, 513, 519, 520,
548, 553, 563, 577, 592, 593, 464, 465, 501: return 2; // Air
default: return 3; // Land
}
return 0;
}
CMD:crash(playerid, params[])
{
new string[128], playerb;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /crash [playerid]");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(playerb, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
SendClientMessage(playerid, COLOR_WHITE, ""•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/");
format(string, sizeof(string), "You have crashed %s 's game", RPN(playerb));
SendClientMessage(playerid,COLOR_RED, string);
format(string, sizeof(string), "AdmWarn: %s has crashed %s his game.", RPN(playerid), RPN(playerb));
SendAdminMessage(COLOR_DARKRED, 1, string);
return 1;
}
stock GetMinute()
{
new Hour,Minute,Second;
gettime(Hour,Minute,Second);
return Minute;
}
stock GetDay()
{
new Year,Month,Day;
getdate(Year, Month, Day);
return Day;
}
stock GetMonth()
{
new Year,Month,Day;
getdate(Year, Month, Day);
return Month;
}
stock GetYear()
{
new Year,Month,Day;
getdate(Year, Month, Day);
return Year;
}
stock GetSecond()
{
new Hour,Minute,Second;
gettime(Hour,Minute,Second);
return Second;
}
stock GetHour()
{
new Hour,Minute,Second;
gettime(Hour,Minute,Second);
return Hour;
}
stock IsLeapYear(year)
{
switch(year)
{
case 2012: return 1;
case 2016: return 1;
case 2020: return 1;
case 2024: return 1;
case 2028: return 1;
case 2032: return 1;
case 2036: return 1;
}
return 0;
}
stock GetDaysInMonth(month)
{
new Year,Month,Day,days;
getdate(Year, Month, Day);
switch(month)
{
case 1: days = 31;
case 2:
{
if(IsLeapYear(Year)) days = 29;
else days = 28;
}
case 3: days = 31;
case 4: days = 30;
case 5: days = 31;
case 6: days = 30;
case 7: days = 31;
case 8: days = 31;
case 9: days = 30;
case 10: days = 31;
case 11: days = 30;
case 12: days = 31;
}
return days;
}
stock ColorLighten(colour,Float:Amount)
{
new a = colour & 0xFF;
new r=min(255, ((colour >> 24) & 0xFF)+ floatround(255 * Amount));
new g=min(255, ((colour >> 16) & 0xFF)+ floatround(255 * Amount));
new b=min(255, ((colour >> 8) & 0xFF)+ floatround(255 * Amount));
return (r<<24 | g<<16 | b<<8 | a);
}
stock ColorDarken(colour,Float:Amount)
{
new a = colour & 0xFF;
new r=max(0, ((colour >> 24) & 0xFF)- floatround(255 * Amount));
new g=max(0, ((colour >> 16) & 0xFF)- floatround(255 * Amount));
new b=max(0, ((colour >> 8) & 0xFF)- floatround(255 * Amount));
return (r<<24 | g<<16 | b<<8 | a);
}
Very simple but useful:
PHP код:
|
// Bunnyhop Detection
#include <a_samp>
new g_JumpCount[MAX_PLAYERS char];
new g_JumpTime[MAX_PLAYERS];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerAnimationIndex(playerid) == 1198)
{
if (GetTickCount() - g_JumpTime[playerid] >= 500)
{
if (++g_JumpCount{playerid} > 4)
{
// Your code here!
g_JumpCount{playerid} = 0;
}
g_JumpTime[playerid] = GetTickCount() + 500;
}
}
return 1;
}
g_JumpCount[playerid] = 0; or g_JumpCount{playerid} = 0;
new g_JumpCount[MAX_PLAYERS]; or new g_JumpCount[MAX_PLAYERS char];
What's the difference between
pawn Код:
pawn Код:
|
math(x, y, op) {
if(!(0 < op < 5))
return 0;
switch(op) {
case 1: {
// ADD
#emit LOAD.S.PRI x
#emit LOAD.S.ALT y
#emit ADD
}
case 2: {
// SUB
#emit LOAD.S.PRI x
#emit LOAD.S.ALT y
#emit SUB
}
case 3: {
// MUL
#emit LOAD.S.PRI x
#emit LOAD.S.ALT y
#emit SMUL
}
case 4: {
// DIV
#emit LOAD.S.PRI x
#emit LOAD.S.ALT y
#emit SDIV
}
}
#emit RETN
return 0;
}
stock gFormatString[2048 char];
#define _format(%0,%1) \
(format(!gFormatString, sizeof(gFormatString), %0, %1), !gFormatString)
SendClientMessage(playerid, COLOR_WHITE, _format("You have $%d. You are very rich!", GetPlayerMoney(playerid));
My own way of inline formatting:
pawn Код:
So basically, with a little tweaking, you can now format strings very easily: pawn Код:
EDIT: I should probably clarify. The reason why it's 512 cells (no, not 2048, it's a packed array) is because you might want to use the function for long inputs, such as MySQL queries and such. |
"format" doesn't support packed strings, you're corrupting data at address 0 (exclamation mark in front of the array) and it can't be split into multiple lines!
|