10.02.2013, 21:48
Useful Snippets
10.02.2013, 22:19
Quote:
Don't know if anyone posted something like this but just created it for myself , could be used by someone:
Код:
stock FindFreeObjectSlot(playerid) { for(new i; i < MAX_PLAYER_ATTACHED_OBJECTS; i++) { if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) { return i; } } return 1; } |
10.02.2013, 22:23
Quote:
pawn Код:
|
10.02.2013, 22:28
Quote:
It's not much...made it in like 5 minutes...but I guess it can be quite useful
Код:
#define COLOR_YELLOW 0xFFFF00AA //<--Incase you don't have yellow defined, add it to the top of your script with all your other definitions #define COLOR_WHITE 0xFFFFFFAA #define COLOR_GRAD1 0xB4B5B7FF CMD:arims(playerid, params[]) { if(IsPlayerAdmin(playerid)) { if(isnull(params)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arims [rim model]"); SendClientMessage(playerid, COLOR_GRAD1, "Rim Models: Cutter, Switch, OffRoad, Shadow, Mega, Rimshine, Wire"); return 1; } if(strcmp(params,"cutter",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Cutter Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1079); } else if(strcmp(params,"switch",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Switch Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1080); } else if(strcmp(params,"offroad",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed OffRoad Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1026); } else if(strcmp(params,"shadow",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Shadow Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1073); } else if(strcmp(params,"mega",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Mega Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1074); } else if(strcmp(params,"rimshine",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Rimshine Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1075); } else if(strcmp(params,"wire",true) == 0) { SendClientMessage(playerid, COLOR_YELLOW, "You have placed Wire Rims on this vehicle."); AddVehicleComponent(GetPlayerVehicleID(playerid), 1076); } } else { SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!"); } return 1; } |
17.04.2013, 13:38
Stock function that will find if a string contains an IP address. Useful for anti advertising.
Example:
pawn Code:
#define MAX_NUM 10
#define MY_SERVER_IP "255.255.255.255:7777"
stock ContainsIP(const string[])
{
new num[MAX_NUM][128];
new numpos[MAX_NUM];
new dotcount,i;
if(strfind(string,MY_SERVER_IP)!=-1)return 0;
for(new npos=0;npos<=MAX_NUM;npos++)
{
new c;
for(c=0;i<strlen(string);i++)
{
new ch = string[i];
if((string[i] == '.' || string[i] == ':') && ((i>0 && '0' <= string[i-1] <= '9') || (i>1 && '0' <= string[i-2] <= '9') ))
{
dotcount++;
i++;
break;
}
if ((npos==0 || i - numpos[npos - 1] < strlen(num[npos-1])+4) && '0' <= ch <= '9' || (c == 0 && ch == '-'))
{
num[npos][c] = string[i];
numpos[npos] = i;
c++;
}
}
}
new found=0;
for(new npos=0;npos<MAX_NUM;npos++)
{
if( strlen(num[npos]) > 0 && 0 < strval(num[npos]) <= 225)
{
found++;
}
}
if(found >= 3 && dotcount >= 3)return 1;
return 0;
}
pawn Code:
public OnPlayerText(playerid, text[])
{
if(ContainsIP(text))
{
BanEx(playerid,"Advertising");
return 0;
}
return 0;
}
18.04.2013, 02:24
Quote:
Stock function that will find if a string contains an IP address. Useful for anti advertising.
pawn Code:
pawn Code:
|
18.04.2013, 09:28
19.04.2013, 11:44
pawn Code:
stock GetPlayerPacketloss(playerid,&Float:packetloss)
{
/* Returns the packetloss percentage of the given playerid - Made by Fusez */
if(!IsPlayerConnected(playerid)) return 0;
new nstats[400+1], nstats_loss[20], start, end;
GetPlayerNetworkStats(playerid, nstats, sizeof(nstats));
start = strfind(nstats,"packetloss",true);
end = strfind(nstats,"%",true,start);
strmid(nstats_loss, nstats, start+12, end, sizeof(nstats_loss));
packetloss = floatstr(nstats_loss);
return 1;
}
19.04.2013, 13:57
20.04.2013, 03:57
Quote:
pawn Code:
|
____
And guys, use the Regex plugin. No need for some complex code when you can just make an expression:
pawn Code:
stock textContainsIP(const string[])
{
static
RegEx:rCIP
;
if ( !rCIP )
{
rCIP = regex_build("(.*?)([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})(.*?)");
}
return regex_match_exid(string, rCIP);
}
21.04.2013, 10:04
Hey I wanted to make this into a filterscript with a warning system but I didn't really feel like it, it's a sound file that plays "Hello user, you have been warned by an admin. Please stop breaking the rules" I think you guys can do something fun with this. Enjoy!
https://dl.dropboxusercontent.com/u/...hello_user.wav
https://dl.dropboxusercontent.com/u/...hello_user.wav
21.04.2013, 11:06
Quote:
Hey I wanted to make this into a filterscript with a warning system but I didn't really feel like it, it's a sound file that plays "Hello user, you have been warned by an admin. Please stop breaking the rules" I think you guys can do something fun with this. Enjoy!
https://dl.dropboxusercontent.com/u/...hello_user.wav |
27.04.2013, 11:21
A command which creates gang zones quickly on the map. The default range specified here is 100, which creates a square model gang zone. You can change it though. It creates square model zones only as it's all set to a specified value, you can change it though.
I use this when I'm lazy to get all the coords.
pawn Code:
CMD:gangzone(playerid, params[])
{
new Float:xp, Float:yp, Float:zp;
GetPlayerPos(playerid, xp, yp, zp);
#pragma unused zp
new range = 100;
new Gangzone = GangZoneCreate(xp-range, yp-range, xp+range, yp+range);
GangZoneShowForAll(Gangzone, 0xFF0000FF);
return 1;
}
10.07.2013, 13:02
a better one here
http://forum.sa-mp.com/showpost.php?...postcount=3990
http://forum.sa-mp.com/showpost.php?...postcount=3990
10.07.2013, 13:37
11.07.2013, 16:11
(
Последний раз редактировалось Dragonsaurus; 11.07.2013 в 16:27.
Причина: Freakin grammar, I post before previewing :p
)
I use something like this (RyDeR's race system):
Only if max players is 100.
Easy...
EDIT: I saw that, of course. But mine is simple, no need for any calculation.
I am aditing just for not posting again
pawn Код:
switch(Position)
{
case 1,21,31,41,51,61,71,81,91: pos = "st";
case 2,22,32,42,52,62,72,82,92: pos = "nd";
case 3,23,33,43,53,63,73,83,93: pos = "rd";
default: pos = "th";
}
Easy...
EDIT: I saw that, of course. But mine is simple, no need for any calculation.
I am aditing just for not posting again
11.07.2013, 19:39
11.07.2013, 22:01
True that:
pawn Код:
stock getOrdinal(iNum) {
static const
s_aszOrdinal[4][3] = { "st", "nd", "rd", "th" }
;
iNum = (iNum < 0) ? -iNum : iNum;
return ((10 < (iNum % 100) < 14) || !(0 < (iNum = (iNum % 10)) < 4)) ? s_aszOrdinal[3] : s_aszOrdinal[iNum - 1];
}
12.07.2013, 00:00
(
Последний раз редактировалось RedFusion; 12.07.2013 в 12:47.
)
EDIT:
pawn Код:
stock GetNumberSuffix(number)
{
new value[20], string[3], length;
format(value, sizeof(value), "%i", number);
length = strlen(value);
if(value[length-1] == '1' && (length == 1 || (length > 1 && value[length-2] != '1'))) string = "st";
else if(value[length-1] == '2' && (length == 1 || (length > 1 && value[length-2] != '1'))) string = "nd";
else if(value[length-1] == '3' && (length == 1 || (length > 1 && value[length-2] != '1'))) string = "rd";
else string = "th";
return string;
}
13.07.2013, 14:50
pawn Код:
stock GetVehicleType(model)
{
switch(model)
{
case 0: return 0; // None
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;
}
« Next Oldest | Next Newest »
Users browsing this thread: 2 Guest(s)