how to remove/delete car when not in use?
#1

how to remove/delete car when not in use 30 seconds?
and how to respawn all cars (admin____command)

give me those pawn code : plzzzzzzzz
Reply
#2

Quote:
Originally Posted by DIVESHSEET
Посмотреть сообщение
how to remove/delete car when not in use 30 seconds?
and how to respawn all cars (admin____command)

give me those pawn code : plzzzzzzzz
This is a FILTERSCRIPT so you will need to add whatever you name this in pawn to your server.cfg

Its a vehicle spawner. it can be for rcon admins only for for everyone. i use it on my server. it works. you will need the vehicle id nuumbers in order to spawn.

Код:
/*
	Vehicle spawn system with anti spam (v1.2) - By Kwarde
	Link to topic: https://sampforum.blast.hk/showthread.ph...#pid879008 - More info there

	You may re-release this script, but only if you keep this comment in the script.
	If you remove it, you may not re-release it.
	You may, off course just edit it. blabla.

	- Kevin
*/

#include <a_samp>
#include <zcmd>

#undef MAX_PLAYERS
#define MAX_SLOTS   	50 //Max players of your server. Changing it is recommended!

#define COLOR_WHITE 	0xFFFFFFAA
#define COLOR_RED   	0xFF0000AA
#define COLOR_GREEN 	0x00FF00AA
#define COLOR_YELLOW    0xFFFF00AA

new bool:RconOnly = true,
		VehicleSpawned[MAX_SLOTS],
		bool:MessageGiven[MAX_SLOTS];

public OnFilterScriptInit()
{
	for(new i = 0; i < MAX_SLOTS; i++){
	    if(VehicleSpawned[i] != -1){
	        DestroyVehicle(VehicleSpawned[i]);
	        VehicleSpawned[i] = (-1);
		}
		MessageGiven[i] = false;
	}
	print("Kwarde's Vehicle Spawn system LOADED");
	return 1;
}

public OnFilterScriptExit()
{
	for(new i = 0; i < MAX_SLOTS; i++){
	    if(VehicleSpawned[i] != -1){
	        DestroyVehicle(VehicleSpawned[i]);
	        VehicleSpawned[i] = (-1);
		}
		MessageGiven[i] = false;
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
	if(VehicleSpawned[playerid] != -1){
	    DestroyVehicle(VehicleSpawned[playerid]);
	    VehicleSpawned[playerid] = (-1);
	}
	MessageGiven[playerid] = false;
	SendClientMessage(playerid, COLOR_RED, "Admins use: /kvechelp");
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(VehicleSpawned[playerid] != -1){
	    DestroyVehicle(VehicleSpawned[playerid]);
	    VehicleSpawned[playerid] = (-1);
	}
	MessageGiven[playerid] = false;
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(!MessageGiven[playerid]){
	    SendClientMessage(playerid, COLOR_RED, "Admins use: /kvechelp");
	    MessageGiven[playerid] = true;
	}
	return 1;
}

CMD:kvechelp(playerid, params[])
{
	if(RconOnly && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	SendClientMessage(playerid, COLOR_YELLOW, "|---------- Kwarde's Vehicle Spawn System ----------|");
	SendClientMessage(playerid, COLOR_WHITE, "** /kvec [ID] -> Spawns a vehicle. [ID] is the vehicle model ID (eg. /kvec 411 for an infernus)");
	SendClientMessage(playerid, COLOR_WHITE, "** /kcallvec -> Calls your spawned vehicle");
	SendClientMessage(playerid, COLOR_WHITE, "** /kgotovec -> Teleports you into your spawned vehicle");
	SendClientMessage(playerid, COLOR_WHITE, "** /kremovevec -> Removes your spawned vehicle");
	SendClientMessage(playerid, COLOR_WHITE, "**!: /krcononly -> Toggle the commands above for RCON only on/off");
	SendClientMessage(playerid, COLOR_WHITE, "**!: /krallvec -> Remove all spawned vehicles");
	SendClientMessage(playerid, COLOR_YELLOW, "|---------- Kwarde's Vehicle Spawn System ----------|");
	return 1;
}

CMD:kvec(playerid, params[])
{
	if(RconOnly && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	new Float:sPos[4];

	if(!strlen(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: {FFFF00}/kvec [ID]");
	if(strval(params) < 400 || strval(params) > 611) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid vehicle model ID");

	if(IsPlayerInAnyVehicle(playerid)){
	    GetVehiclePos(GetPlayerVehicleID(playerid), sPos[0], sPos[1], sPos[2]);
	    GetVehicleZAngle(GetPlayerVehicleID(playerid), sPos[3]);
	    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	        SetVehicleToRespawn(GetPlayerVehicleID(playerid));
		else
		    RemovePlayerFromVehicle(playerid);
	}
	else{
	    GetPlayerPos(playerid, sPos[0], sPos[1], sPos[2]);
	    GetPlayerFacingAngle(playerid, sPos[3]);
	}
	if(VehicleSpawned[playerid] != -1)
	    DestroyVehicle(VehicleSpawned[playerid]);
	VehicleSpawned[playerid] = CreateVehicle(strval(params[0]), sPos[0], sPos[1], sPos[2], sPos[3], -1, -1, -1);
	SetVehicleVirtualWorld(VehicleSpawned[playerid], GetPlayerVirtualWorld(playerid));
	LinkVehicleToInterior(VehicleSpawned[playerid], GetPlayerInterior(playerid));
	PutPlayerInVehicle(playerid, VehicleSpawned[playerid], 0);
	SendClientMessage(playerid, COLOR_GREEN, "* Your vehicle has been spawned.");
	return 1;
}

CMD:kcallvec(playerid, params[])
{
	if(RconOnly && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	if(VehicleSpawned[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You didn't spawn a vehicle yet.");
	new Float:sPos[4];
	if(IsPlayerInAnyVehicle(playerid)){
	    GetVehiclePos(GetPlayerVehicleID(playerid), sPos[0], sPos[1], sPos[2]);
	    GetVehicleZAngle(GetPlayerVehicleID(playerid), sPos[3]);
	    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	        SetVehicleToRespawn(GetPlayerVehicleID(playerid));
		else
		    RemovePlayerFromVehicle(playerid);
	}
	else{
	    GetPlayerPos(playerid, sPos[0], sPos[1], sPos[2]);
	    GetPlayerFacingAngle(playerid, sPos[3]);
	}
	RemoveAllPlayersFromVehicle(VehicleSpawned[playerid]);
	SetVehiclePos(VehicleSpawned[playerid], sPos[0], sPos[1], sPos[2]);
	SetVehicleZAngle(VehicleSpawned[playerid], sPos[3]);
	SetVehicleVirtualWorld(VehicleSpawned[playerid], GetPlayerVirtualWorld(playerid));
	LinkVehicleToInterior(VehicleSpawned[playerid], GetPlayerInterior(playerid));
	PutPlayerInVehicle(playerid, VehicleSpawned[playerid], 0);
	SendClientMessage(playerid, COLOR_GREEN, "* Your vehicle has been called.");
	return 1;
}

CMD:kgotovec(playerid, params[])
{
	if(RconOnly && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	if(VehicleSpawned[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You didn't spawn a vehicle yet.");
	RemoveAllPlayersFromVehicle(VehicleSpawned[playerid]);
	PutPlayerInVehicle(playerid, VehicleSpawned[playerid], 0);
	SendClientMessage(playerid, COLOR_GREEN, "* You've been teleported to your vehicle");
	return 1;
}

CMD:kremovevec(playerid, params[])
{
	if(RconOnly && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	if(VehicleSpawned[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You didn't spawn a vehicle yet.");
	DestroyVehicle(VehicleSpawned[playerid]);
	VehicleSpawned[playerid] = (-1);
	SendClientMessage(playerid, COLOR_GREEN, "* Your vehicle has been removed.");
	return 1;
}

CMD:krcononly(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	if(RconOnly){
	    RconOnly = false;
	    SendClientMessageToAll(COLOR_GREEN, "Vehicle Spawner available for everyone. (/kvechelp)");
	}
	else{
	    RconOnly = true;
	    SendClientMessageToAll(COLOR_RED, "* Kwarde's Vehicle Spawn System is now only avaible for RCON admins!");
	}
	return 1;
}

CMD:krallvec(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This is for RCON admins only!");
	for(new i = 0; i < MAX_SLOTS; i++){
	    if(VehicleSpawned[i] != -1){
	        DestroyVehicle(VehicleSpawned[i]);
	        VehicleSpawned[i] = (-1);
		}
		MessageGiven[i] = false;
	}
	SendClientMessageToAll(COLOR_RED, "All spawned vehicles have removed by an Admin");
	return 1;
}

stock RemoveAllPlayersFromVehicle(vehicleid)
{
	for(new i = 0; i < MAX_SLOTS; i++)
	    if(IsPlayerInVehicle(i, vehicleid))
	        RemovePlayerFromVehicle(i);
	return 1;
}
Reply
#3

yeah i know .. i already have a vehicle command (/sutan etc)and i just need a anti car spam and remove the car when not in use
Reply
#4

Just use the last parameter in AddStaticVehicleEx or CreateVehicle.
Reply
#5

something like this :
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
DestroyVehicle(vehicleid);
SendClientMessage(playerid, GREEN,"NEWS: Your vehicle has been destroyed to avoid vehicle spam in server");
}
  return 1;
}
This on Top :
Quote:

#define GREEN 0x15FF00AA

Reply
#6

Quote:
Originally Posted by Kells
Посмотреть сообщение
something like this :
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
DestroyVehicle(vehicleid);
SendClientMessage(playerid, GREEN,"NEWS: Your vehicle has been destroyed to avoid vehicle spam in server");
}
  return 1;
}
This on Top :
That will work fine, but, it won't look good from server side, The best way, could be Auto-Clear system, which clears after a hour or two.
That can be done by using foreach, and when player spawns a vehicle, add the vehicle id to iterator.
then you'd need 2 variables, on for player last vehicle, and other bool for all vehicles, if it is occupied.
The occupied check can be done under OnPlayerUpdate;
pawn Код:
public OnPlayerUpdate(playerid) {
if(IsPlayerInVehicle(playerid,LastVehicle[playerid])){
if(VehicleOccupied[LastVehicle[playerid]] == false) {
VehicleOccupied[LastVehicle[playerid] = true;
}
} else {
if(!IsPlayerInVehicle(playerid,LastVehicle[playerid])){
if(VehicleOccupied[LastVehicle[playerid]] == true) {
VehicleOccupied[LastVehicle[playerid] = false;
}
}
}
return 1;
}
That was just an example.
Reply
#7

KELLS i was searching your pawn code so long ... thanks man you are a god ... but how to put a timer (30 seconds) before the car varnish
Reply
#8

https://sampwiki.blast.hk/wiki/CreateVehicle
and you could destroy vehicle when it respawns
https://sampwiki.blast.hk/wiki/OnVehicleSpawn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)