Useful Snippets
#81

Quote:
Originally Posted by Seif[P7
]
Sandra, how could that be possible? Once EraseVehicle is called, it should do its job, by setting your pos higher, setting the vehicle to respawn, locking it and sets a timer that'll destroy it in 3 seconds. I don't see why it'd be called many times non-stop.
Quote:
Originally Posted by Seif[P7
]
pawn Code:
public OnVehicleSpawn(vehicleid) if (vehicleid == 5) return EraseVehicle(vehicleid);
Since you call the function at every vehiclespawn..
Reply
#82

Quote:
Originally Posted by Seif[P7
]
Ugh, you got it wrong. That was an EXAMPLE of the usage of EraseVehicle...
Oh ok, so just unefficient example.
Reply
#83

Pixels, Your code (DestroyVehicle fix) is rather Bugged.

The Variable Name:

Code:
new dStroy[];
Is Bugged, It gives off an Invalid array size error.

Also take a look at this line:

Code:
for(new p=0; p<200; p++) if(IsPlayerConnected(p) && IsPlayerInVehicle(p,i) == false) vCount++;
Tag Mismatch...

And, You also forgot to forward it

Oh, and one more thing while Im here
Your callback for OnPlayerGetMoney, which I use a lot (Thanks btw ) Only works with Player id 0
Reply
#84

Quote:
Originally Posted by Grove
Oh, and one more thing while Im here
Your callback for OnPlayerGetMoney, which I use a lot (Thanks btw ) Only works with Player id 0
It's probably a loop problem you have.
Reply
#85

pawn Code:
new bool:KillVeh[MAX_VEHICLES] = false;

KillVehicle(vehicleid)
{
  KillVeh[vehicleid] = true;
  SetVehicleToRespawn(vehicleid);
}

OnVehicleSpawn(vehicleid)
{
  if(KillVeh[vehicleid])
  {
    KillVeh[vehicleid] = false;
    DestroyVehicle(vehicleid);
  }
}
I just wrote that straight into the forum. I use something similar to that in my mode and it works fine. No timers needed.
Reply
#86

Nice one boylett

@ Pixels, The looping I use is fine, I made my own callback for it anyway, Im just pointing out that yours was a little bugged
Reply
#87

Quote:
Originally Posted by Seif[P7
]
Firstname_Lastname
This is meant for RP purposes. Allowing only a correct format such as Firstname_Lastname, nothing else

pawn Code:
public OnPlayerConnect(playerid) return NameKicker(playerid);

stock NameKicker(playerid)
{
  if (IsPlayerConnected(playerid))
  {
    new player[24];
    GetPlayerName(playerid,player,24);
    for(new n = 0; n <= strlen(player); n++)
    if (player[n] != '_' || player[n] == '[' || player[n] == ']' || player[n] == '{' || player[n] == '}')
    {
      SendClientMessage(playerid,0xE60000FF,"Wrong name format. Please reconnect using the correct name format like this: Firstname_Lastname");
      SendClientMessage(playerid,0x33AA33AA,"Example: Michael_Taylor");
      Kick(playerid);
    }
    else return 1;
  }
  return 1;
}
This code cause one error in my pawno..i add
pawn Code:
return NameKicker(playerid);
on this mode

pawn Code:
public OnPlayerConnect(playerid) return NameKicker(playerid);
And this, cause error in my pawno...

This code are right ?
Reply
#88

Oh, sorry for noob post, but you need to remove the caracters:

pawn Code:
player[n] != '_' ||
Or it kick one right name...

I tested it now, my nick normal has been kicked, but my nick right are kicked off, an, i remove the caracters, an its work fine again
Reply
#89

Yep, remove this of code, or it kick one nick id have "_"
Reply
#90

Anti Slap by R@f
Very easy but usefull for stunt servers ! It freeze the player for 1 second when he press the fire key
Код:
//above main
forward Unfreeze (playerid);

//OnPlayerKeyStateChange
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if ((newkeys & KEY_FIRE))
	{
		if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
		TogglePlayerControllable(playerid,0);
		SetTimerEx("Unfreeze",1,0,"i",playerid);
		}
	}
}

//some where in the script
public Unfreeze(playerid)
{
TogglePlayerControllable(playerid,1);
}
Enjoy
R@f
Reply
#91

I hate to use SendRconCommand to set the mapname.
So i scripted this little function.
pawn Код:
stock SetGameMapName(const mapname[])
{
    new string[256];
    format(string, sizeof(string), "mapname %s", mapname);
    SendRconCommand(string);
}
Reply
#92

Simple Advertiser
by: fujinnn

that script will advertise evry 5 minutes (*you can change) all that you want!

Top of your script:
Код:
forward AutoMsg();
OnGameModeInit()
Код:
SetTimer("AutoMsg",300000,1); // Auto message in evry 5 minutes
Create a new 'public' in the end or middle of your script
Код:
public AutoMsg()
{
	SendClientMessageToAll(0xFF1493AA, "SERVER: *Want to Advertise here? Contact fujinnn");
	return 1;
}
thats it! simple as hell..

[color=red]* that is my first release


enjoy!
Reply
#93

Here is some random useless things for most people!
Prints all the text into 1 file:
Код:
public OnPlayerText(playerid, text[])
{
	new string[256], pname[24], File:ftw = fopen("Text.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	format(string, sizeof (string), "%s:%s \r\n",pname,text);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
Prints all the PM's to a file:
Код:
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	new string[256], pname[24],pname1[24], File:ftw = fopen("PM's.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	GetPlayerName(recieverid, pname, 24);
	format(string, sizeof (string), "From:%s To:%s Message:%s \r\n",pname,pname1,text);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
Prints all the typed commands to a file:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256], pname[24], File:ftw = fopen("Commands.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	format(string, sizeof (string), "Command:%s Used By:%s \r\n",cmdtext,pname);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
Reply
#94

Count Vehicles In Server
PasteBin link, for ready to use FS

Displays how many vehicles are in your server, only way i could think of, and no fancy shit

news:
pawn Код:
new CounterID, Count, String[32];
command:
pawn Код:
if(!strcmp(cmdtext, "/countcars", true, 10))
    {
      CounterID = playerid;
      for(new i = 0; i < MAX_VEHICLES; i ++)
        SetVehicleToRespawn(i);
      SetTimer("DisplayVehicles", 5000, 0);
      return 1;
    }
Put this in OnVehicleSpawn:
pawn Код:
Count = vehicleid;
And the function to display the amount of cars:
pawn Код:
forward DisplayVehicles();
public DisplayVehicles()
{
    format(String, sizeof(String), "%d Vehicles counted", Count);
    SendClientMessage(CounterID, 0xFFFFFF, String);
}
Im pretty sure someone else's thought of this already, but here is it in the Useful Snippets topic!

EDIT: can this topic be stickied too?
Reply
#95

I made a vehicle-counter Filterscript today . It has some more functions such as model counter and warnings.
And It's written easier without respawning cars or even touching them in any way!! And So u can even use it with all VehicleSlots Used!
DOWNLOAD HERE KLICK

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

	if (strcmp("/carcheck", cmdtext, true, 10) == 0)
	{
	SendClientMessage(playerid,0xFFFF00AA, "Carcheck introduced!");
	new Models[211]=0;
	new cars=0;
	new mods=0;
	for(new i; i<=MAX_VEHICLES;i++)
		{
			if(400<=GetVehicleModel(i)<=611)
			{
			  cars++;
			  Models[GetVehicleModel(i)-400]=1;
			}
		}
	for(new o;o<=210;o++)
	{
		if(Models[o]==1) mods++;
	}
	new message[256];
	format(message, sizeof(message), "%d cars with %d different models!", cars, mods);
	if(cars>=550)
		{
		  new message2[256];
		  new message21[256];
		  format(message2, sizeof(message2), "Remember you only have %d cars left", 700-cars);
 		  format(message21, sizeof(message21), "And only around %d stable.", 650-mods);
		  SendClientMessage(playerid, 0xFF6347AA, message2);
		  SendClientMessage(playerid, 0xFF6347AA, message21);
 		}
 	if(mods>=50)
		{
		  new message3[256];
		  new message31[256];
		  format(message3, sizeof(message3), "Remember you only have %d models left", 70-mods);
 		  format(message31, sizeof(message31), "And only around %d stable.", 65-mods);
		  SendClientMessage(playerid, 0xFF6347AA, message3);
 		  SendClientMessage(playerid, 0xFF6347AA, message31);
 		}
	SendClientMessage(playerid, 0xFFFF00AA, message);
	return 1;
	}
	return 0;
}
NOTE: this is part of a filterscript. If u wanna use it directly in your gamemode, u have to change the returns at OnPlayerCommandText!
Reply
#96

To know ur Vehicle id :


Код:

 	if(strcmp(cmdtext, "/vid", true) == 0)
 		{
 		new tmp,str[256];
 		tmp = GetPlayerVehicleID(playerid);
 		format(str,256,"[INFO] Vehicle id: %d",tmp);
 		SendClientMessage(playerid, COLOR_YELLOW, str);
 		return 1;
 		}
Reply
#97

Quote:
Originally Posted by Alejandro
Connect icon in DeathStats from ******
pawn Код:
public OnPlayerConnect(playerid)
{
  SendDeathMessage(playerid, INVALID_PLAYER_ID, 200);
  return 1;
}

Disconnect icon in DeathStats from ******
pawn Код:
public OnPlayerDisconnect(playerid)
{
  SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
}
the disconnect icon shows for me, but the connect icon wont show.
[/quote]
for me is don't showing any icon
Reply
#98

Anti Labrik Spam
This is defense against the spamming tool which spams your server with "FUCK THIS SERVER" and also spams join/leave. True that it will ban anyone with this name but I don't think someone that uses this name in the first place should join your server. This should be 100% perfect if people do this to your server, as the first join name is Labrik and the first IP is the attackers IP instead of the fake IP's that appear most of the time afterwards.

pawn Код:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[ViP]Labrik",name,true))
{
Ban(playerid);
}
return 1;
}
Reply
#99

Quote:
Originally Posted by JaTochNietDan
Anti Labrik Spam
This is defense against the spamming tool which spams your server with "FUCK THIS SERVER" and also spams join/leave. True that it will ban anyone with this name but I don't think someone that uses this name in the first place should join your server. This should be 100% perfect if people do this to your server, as the first join name is Labrik and the first IP is the attackers IP instead of the fake IP's that appear most of the time afterwards.

pawn Код:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[ViP]Labrik",name,true))
{
Ban(playerid);
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[MT]Lavis",name,true))
{
Ban(playerid);
}
return 1;
}
Reply

Or:

//On top of your script:
Код:
new BannedNames[][MAX_PLAYER_NAME] = 
{
  "[ViP]Labrik", 
  "[MT]Lavis",
  "[XXX]Whatever"
}; //Add as much as you want.
Код:
public OnPlayerConnect(playerid)
{
  new Name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(Name));
  for(new i; i<sizeof(BannedNames); i++)
  {
    if(strcmp(BannedNames[i],Name,true)==0)
    {
      Ban(playerid);
    }
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 46 Guest(s)