Re: Useful Snippets -
MenaceX^ - 07.04.2009
Quote:
Originally Posted by ♣ ⓐⓢⓢ
thought there were already a anti-driveby filterscript release, so this is unused
|
It isn't an anti driveby code. It just doesn't let you take shotgun/armor from the SWAT car.
Re: Useful Snippets -
FrazZ - 07.04.2009
[color=red]General Saints Hospital Code
-This is for people who want the general saints hospital to have an option to /healme. You can change the amount it charges in the code.
Put this at the top of your script:
Put this below "CreateVehicle"s:
Код:
hospitalpickup = CreatePickup(1240,1,1172.6083,-1323.5745,15.4031); // Hospital
Put this at the very bottom under "OnPlayerPickUpPickup":
Код:
if (pickupid == hospitalpickup)
{
GameTextForPlayer(playerid, "~r~General Saints Hospital~n~~y~Type /healme to be healed~n~Healing: 300$",5000, 3);
}
}
And lastly, put this somewhere in "OnPlayerCommandText":
Код:
if (strcmp(cmdtext, "/healme", true) == 0)
{
if(PlayerToPoint(3, playerid, 1172.6083,-1323.5745,15.4031)) // 24/7 enterance
if(GetPlayerMoney(playerid) > 300)
{
GivePlayerMoney(playerid,-300);
SendClientMessage(playerid, COLOR_WHITE, "You have been healed for 300$");
SendClientMessage(playerid, COLOR_RED, "If you didn't get healed, you");
SendClientMessage(playerid, COLOR_RED, "obviously don't have enough money.");
SetPlayerHealth(playerid,100);
}
return 1;
}
You can edit that code and set the amount it charges:
Код:
if(GetPlayerMoney(playerid) > 300)
It will check if the player has that amount.
Код:
GivePlayerMoney(playerid,-300);
This will subtract money. Change the -300 to whatever you want.
Hope it helps.
Re: Useful Snippets -
Nero_3D - 07.04.2009
Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by ♣ ⓐⓢⓢ
thought there were already a anti-driveby filterscript release, so this is unused
|
It isn't an anti driveby code. It just doesn't let you take shotgun/armor from the SWAT car.
|
enforcer only give armour, so 50% of the code is unused
Re: Useful Snippets -
Weirdosport - 25.04.2009
- Clan Tag detection/removal snippet:
pawn Код:
stock RemoveClanTagFromName(playerid)
{
new start, end, string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
start = strfind(string, "[", true);
end = strfind(string, "]", true);
if(start >= end) return 0;
else
{
strdel(string, start, end + 1);
SetPlayerName(playerid, string);
return 1;
}
}
pawn Код:
stock TagDetect(playerid)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
if(strfind(string, "]", true) > strfind(string, "[", true)) return 1;
else return 0;
}
RemoveClanTagFromName(playerid) - does that it says on the tin, and returns 0 if the player doesn't have a clantag.
TagDetect(playerid) - is a simpler version of the above, and can be used in a script to stop someone getting 2 clantags. It returns 1 if the player already has a clantag, and 0 if they do not.
Both of these scripts work with clantags situated anywhere in the name.
- [LS]Weirdosport
- Weirdo[LS]sport
- Weirdosport[LS]
All of these examples become Weirdosport when used. If the player has multiple clan tags, it will remove them one by one.
For example, a (nooby) person connects to the server, with the username [l]o[l]o[l], and decides he wants his tags removing:- After the first iteration, his name will be o[l]o[l].
- Then it will become oo[l]
- And finally oo
If you have any further questions, PM me, don't expect me to check this thread daily...
Re: Useful Snippets -
pen_theGun - 25.04.2009
Quote:
Originally Posted by Weirdosport
Clan Tag detection/removal snippet:
pawn Код:
stock RemoveClanTagFromName(playerid) { new start, end, string[MAX_PLAYER_NAME]; GetPlayerName(playerid, string, sizeof(string)); start = strfind(string, "[", true); end = strfind(string, "]", true); if(start >= end) return 0; else { strdel(string, start, end + 1); SetPlayerName(playerid, string); return 1; } }
|
Using this on Playernames like < [Qwertzu], [Pepe] > will crash the server..
Re: Useful Snippets -
CJ101 - 04.05.2009
Код:
forward IsInCar(playerid);
forward IsInPlane(playerid);
forward IsInBoat(playerid);
public IsInCar(playerid)
{
new vehm;
vehm = GetVehicleModel(GetPlayerVehicleID(playerid));
if (vehm != 548 || vehm != 469 || vehm != 447 || vehm != 563 || vehm != 497 || vehm != 488 || vehm != 487 || vehm != 417 || vehm != 425)
{
return true;
}
else
{
return false;
}
}
public IsInBoat(playerid)
{
new vehm;
vehm = GetVehicleModel(GetPlayerVehicleID(playerid));
if (vehm == 472 || vehm == 473 || vehm == 493 || vehm == 595 || vehm == 484 || vehm == 430 || vehm == 453 || vehm == 452 || vehm == 446 || vehm == 454)
{
return true;
}
else
{
return false;
}
}
public IsInPlane(playerid)
{
new vehm;
vehm = GetVehicleModel(GetPlayerVehicleID(playerid));
if (vehm == 548 || vehm == 469 || vehm == 447 || vehm == 563 || vehm == 497 || vehm == 488 || vehm == 487 || vehm == 417 || vehm == 425)
{
return true;
}
else
{
return false;
}
}
Re: Useful Snippets -
Donny_k - 05.05.2009
Quote:
Originally Posted by cj101
|
Why are they all public dude and do you know 'switch' exists, it can save a lot of time and processing in most cases.
Example:
pawn Код:
IsPlayerInPlane( playerid )
{
if ( !IsPlayerInAnyVehicle( playerid ) ) return false; //this will save doing the model/switch code if true
new
v = GetVehicleModel( GetPlayerVehicleID( playerid ) );
switch ( v )
{
case 548, 469, 447, 563, 497, 488, 487, 417, 425 : return true;
}
return false;
}
Take a look at that code then at your code, you will see how different it is but it does the same thing.
Re: Useful Snippets -
yom - 05.05.2009
Donny you don't need the new v because the switch statement is evaluated only once :P
Re: Useful Snippets -
Donny_k - 05.05.2009
Quote:
Originally Posted by 0rb
Donny you don't need the new v because the switch statement is evaluated only once :P
|
I wasn't sure if it only performed the single instruction on the element or it did indeed have to recall on each case, I went safe but obviously I was wrong so thanks for the correction dude.
Revised code:
pawn Код:
IsPlayerInPlane( playerid )
{
// no need for the first check now as the case will be 0 so it will return false, single instruction ftw :)
switch ( GetVehicleModel( GetPlayerVehicleID( playerid ) ) )
{
case 548, 469, 447, 563, 497, 488, 487, 417, 425 : return true;
}
return false;
}
Re: Useful Snippets -
MenaceX^ - 08.05.2009
Quote:
Originally Posted by Donny
Quote:
Originally Posted by 0rb
Donny you don't need the new v because the switch statement is evaluated only once :P
|
I wasn't sure if it only performed the single instruction on the element or it did indeed have to recall on each case, I went safe but obviously I was wrong so thanks for the correction dude.
Revised code:
pawn Код:
IsPlayerInPlane( playerid ) { // no need for the first check now as the case will be 0 so it will return false, single instruction ftw :) switch ( GetVehicleModel( GetPlayerVehicleID( playerid ) ) ) { case 548, 469, 447, 563, 497, 488, 487, 417, 425 : return true; } return false; }
|
or
pawn Код:
IsPlayerInPlane( playerid )
{
switch ( GetVehicleModel( GetPlayerVehicleID( playerid ) ) )
case 548, 469, 447, 563, 497, 488, 487, 417, 425 : return true;
return false;
}
Less lines :> (owned)
I really dislike to do things with useless lines.
Re: Useful Snippets -
im2fast4u - 12.09.2009
nice work
Re: Useful Snippets -
Calgon - 16.09.2009
Ping Kicker.
pawn Код:
public PingCheck()
{
new MAX_PING = 600;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsPlayerAdmin(i))
{
new ping, string[128];
ping = GetPlayerPing(i);
if(ping >= MAX_PING)
{
format(string, sizeof(string), "Excessive Ping (%d) - Above %d.", ping, MAX_PING);
Kick(i);
}
}
}
}
}
Re: Useful Snippets -
Mikep. - 16.09.2009
Wow that's one messy code.
pawn Код:
public PingCheck()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerAdmin(i) && IsPlayerConnected(i))
{
new string[128];
if(GetPlayerPing(i) > 600)
{
format(string, sizeof(string), "Excessive Ping (%i) - Above 600.", ping);
SendClientMessage(playerid, COLOR_RED, string);
Kick(i);
}
}
}
return 1;
}
You never sent the string, you created a variable when it wasn't needed, you did two seperate checks instead of using &&. Just pointing out what I changed.
Re: Useful Snippets -
Calgon - 16.09.2009
Quote:
Originally Posted by Mikep.
Wow that's one messy code.
pawn Код:
public PingCheck() { for(new i=0; i<MAX_PLAYERS; i++) { if(!IsPlayerAdmin(i) && IsPlayerConnected(i)) { new string[128]; if(GetPlayerPing(i) > 600) { format(string, sizeof(string), "Excessive Ping (%i) - Above 600.", ping); SendClientMessage(playerid, COLOR_RED, string); Kick(i); } } } return 1; }
You never sent the string, you created a variable when it wasn't needed, you did two seperate checks instead of using &&. Just pointing out what I changed.
|
I'm half asleep. But thanks.
Re: Useful Snippets -
Calgon - 16.09.2009
PingCheck() moved to 'Useful Functions'.
pawn Код:
new string[128], RconPass;
RconPass = random(999999);
format(string, sizeof(string), "rcon_password %d", RconPass);
SendRconCommand(string);
printf("[SYSTEM] A new RCON password has been set (%d).", RconPass);
The way I use it is on every PayDay the RCON password is automatically changed. RconPass is defined at the top of the script and the code is in PayDay().
Re: Useful Snippets -
Google63 - 25.09.2009
Quote:
Originally Posted by MenaceX^
This isn't supposed to be in useful snippers.
I like to use that way for ycmd as it requires you to make a forward + public so you could just do y_cmd instead of ycmd.
pawn Код:
#define y_cmd%0(%1) forward %0(%1); public %0(%1)
|
ycmd has its macro > Command_(command-name) wich is same as yours
Re: Useful Snippets -
MenaceX^ - 25.09.2009
Quote:
Originally Posted by JoeBullet
Quote:
Originally Posted by MenaceX^
This isn't supposed to be in useful snippers.
I like to use that way for ycmd as it requires you to make a forward + public so you could just do y_cmd instead of ycmd.
pawn Код:
#define y_cmd%0(%1) forward %0(%1); public %0(%1)
|
ycmd has its macro > Command_(command-name) wich is same as yours ![Wink](images/smilies/wink.png)
|
Oh, sorry. I didn't know. I never looked trought the ycmd but I remember Y_Less scripting in a forward and public so I thought this might be coolest
Re: Useful Snippets -
ruarai - 28.09.2009
1337 tr4nsl470r
pawn Код:
public OnPlayerText(playerid, text[])
{
for(new i; i < strlen(text); i++)
{
if(text[i] == 'a') text[i] = '4';
if(text[i] == 'e') text[i] = '3';
if(text[i] == 'l') text[i] = '1';
if(text[i] == 'o') text[i] = '0';
if(text[i] == 's') text[i] = '5';
if(text[i] == 't') text[i] = '7';
}
SendPlayerMessageToAll(playerid,text);
return 0;
}
Thanks to jeff for noticing what was wrong with it!
Re: Useful Snippets -
dice7 - 28.09.2009
That will change the text from 'lol' to '101' which I don't see useful.
And make
pawn Код:
new lenght = strlen(text);
for(new i;i < lenght; i++)
The old one will, if the text is 100 chars long, call strlen 100 times to compare with i and just eat up resources
Re: Useful Snippets -
MenaceX^ - 03.10.2009
Quote:
Originally Posted by CalgonX
Ping Kicker.
pawn Код:
public PingCheck() { new MAX_PING = 600; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(!IsPlayerAdmin(i)) { new ping, string[128]; ping = GetPlayerPing(i); if(ping >= MAX_PING) { format(string, sizeof(string), "Excessive Ping (%d) - Above %d.", ping, MAX_PING); Kick(i); } } } } }
|
That might do problems because when the player connects, the player has something like 65000 ping. So it'll kick him.