All pastes #2105655 Raw Edit

Unnamed

public text v1 · immutable
#2105655 ·published 2012-01-24 12:53 UTC
rendered paste body
/*
                        This filterscript is made by Wesley221
                        You're alowed to use this filterscript in your server, aslong you keep the credits
                        Do NOT re-release this filterscript, and do not claim it as your own
*/
//==============================================================================
//
// Includes
//
//==============================================================================
#include                                <a_samp>
#include                                <zcmd>
#include                <sscanf2>
 
//==============================================================================
//
// Defines
//
//==============================================================================
/* NOTE: Just use true/false! */
/* Boring defines */
#define USE_ADMIN       true // if true, you need to be admin to do this
#define PAY_CMD                 false // if true, you need to pay an amount of cash to use this command
#define USE_RMESSAGE    true // if true, it automaticly sends messages to everyone
#define PAY                     1000 // the amount you need to pay to use a command
/* The random messages, change them if you dont like it */
#define MESSAGE1        "This server uses VehicleSpawner from Wesley221 (/spawnhelp)"
#define MESSAGE2        "/spawnhelp for all the commands of this filterscript! (/spawnhelp)"
#define MESSAGE3        "Spawning something only costs $%i! (/spawnhelp)"
#define MESSAGE4        "/(v/w) [vehicle/weaponname] to spawn a vehicle/weapon! No ID's needed! (/spawnhelp)"
#define MESSAGE5        "Out of ideas! Change this line to anything you like! (/spawnhelp)"
/* Colours */
#define C_RED                   0xFF0000FF
#define C_GREEN         0x00FF00FF
 
//==============================================================================
//
// Vehicle and weapon names
//
//==============================================================================
new aVehicleNames[212][] =
{
        {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},{"Firetruck"},{"Trashmaster"},{"Stretch"},
        {"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},
        {"Washington"},{"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},{"Banshee"},{"Predator"},{"Bus"},
        {"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},
        {"Monster"},{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},
        {"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
        {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},{"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},
        {"BMX"},{"Burrito"},{"Camper"},{"Marquis"},{"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
        {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},{"Mesa"},{"RC Goblin"},{"Hotring Racer A"},
        {"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},{"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
        {"Tanker"},{"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},
        {"Fortune"},{"Cadrona"},{"FBI Truck"},{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},{"Blade"},{"Freight"},
        {"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},{"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
        {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},
        {"Flash"},{"Tahoma"},{"Savanna"},{"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},{"Broadway"},{"Tornado"},{"AT-400"},
        {"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},{"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
        {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},{"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},
        {"Alpha"},{"Phoenix"},{"Glendale"},{"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},{"Utility Trailer"}
};
new aWeaponNames[47][] =
{
        {"Unarmed"},{"Brass Knuckles"},{"Golf Club"},{"Nite Stick"},{"Knife"},{"Baseball Bat"},{"Shovel"},{"Pool Cue"},{"Katana"},{"Chainsaw"},{"Purple Dildo"},
        {"Smal White Vibrator"},{"Large White Vibrator"},{"Silver Vibrator"},{"Flowers"},{"Cane"},{"Grenade"},{"Tear Gas"},{"Molotov Cocktail"},
        {""},{""},{""}, // Empty spots for ID 19-20-21 (invalid weapon id's)
        {"9mm"},{"Silenced 9mm"},{"Desert Eagle"},{"Shotgun"},{"Sawn-off Shotgun"},{"Combat Shotgun"},{"Micro SMG"},{"MP5"},{"AK-47"},{"M4"},{"Tec9"},
        {"Country Rifle"},{"Sniper Rifle"},{"Rocket Launcher"},{"HS Rocket Launcher"},{"Flamethrower"},{"Minigun"},{"Satchel Charge"},{"Detonator"},
        {"Spraycan"},{"Fire Extinguisher"},{"Camera"},{"Nightvision Goggles"},{"Thermal Goggles"},{"Parachute"}
};
 
//==============================================================================
//
// Commands
//
//==============================================================================
/* Spawn vehicle */
COMMAND:v(playerid, params[])
{
        #if USE_ADMIN == true
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, C_RED, " ** You need to be an admin (RCON) to use this command! ");
        #endif
        new Vehicle[50];
        if(!sscanf(params, "s[50]", Vehicle))
        {
                new string[128], Float:Pos[4];
                GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
                new veh = GetVehicleModelID(Vehicle);
                if(veh < 400 || veh > 611) return SendClientMessage(playerid, C_RED, " ** This is not a valid vehicle name! Please try again ");
                if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
                GetXYInFrontOfPlayer(playerid, Pos[0], Pos[1], 5);
                new PVeh = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3]+90, -1, -1, -1);
                LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
                #if PAY_CMD == true
                GivePlayerMoney(playerid, - PAY);
                format(string, sizeof string, " ** You spawned a %s. ID: %i. You paid: $%i", aVehicleNames[veh - 400], veh, PAY);
                #else
                format(string, sizeof string, " ** You spawned a %s. ID: %i. ", aVehicleNames[veh - 400], veh);
                #endif
                SendClientMessage(playerid, C_GREEN, string);
        } else return SendClientMessage(playerid, C_GREEN, " ** Usage: /v(eh)(icle) [vehiclename] ");
        return 1;
}
 
/* Spawn weapon */
COMMAND:w(playerid, params[])
{
        #if USE_ADMIN == true
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, C_RED, " ** You need to be an admin (RCON) to use this command! ");
        #endif
        new Weapon[50], Ammo;
        if(!sscanf(params, "s[50]I(500)", Weapon, Ammo))
        {
            new string[128], weapon = GetWeaponID(Weapon);
            if(weapon < 0 || weapon > 46 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 22) return SendClientMessage(playerid, C_RED, " ** This is not a valid weapon name! PLease try again");
            if(Ammo <= 500 || Ammo > 10000) return SendClientMessage(playerid, C_RED, " ** Minimum ammo: 500 Maximum ammo: 10000 ");
                GivePlayerWeapon(playerid, weapon, Ammo);
                #if PAY_CMD == true
                new moneycheck[128];
                if(GetPlayerMoney(playerid) < PAY) return format(moneycheck, sizeof moneycheck, " ** You do not have enough money to buy this weapon! Money required: $%i. Money needed: $%i", PAY, PAY - GetPlayerMoney(playerid)) && SendClientMessage(playerid, C_RED, moneycheck);
                GivePlayerMoney(playerid, - PAY);
                format(string, sizeof string, " ** You spawned a %s (Ammo: %i). ID: %i. You paid: $%i", aWeaponNames[weapon], Ammo, weapon, PAY);
                #else
                format(string, sizeof string, " ** You spawned a %s (Ammo: %i). ID: %i. ", aWeaponNames[weapon],Ammo, weapon);
                #endif
                SendClientMessage(playerid, C_GREEN, string);
        } else return SendClientMessage(playerid, C_GREEN, " ** Usage: /w(eap)(on) [weaponname] [ammo] ");
 
        return 1;
}
 
/* Command help */
COMMAND:spawnhelp(playerid, cmdtext[])
{
        SendClientMessage(playerid, C_GREEN, " -|_|- Vehicle/weapon spawn help -|_|- ");
        SendClientMessage(playerid, C_RED, " - /v(eh)(icle) [vehiclename] > Spawns a vehicle of your choice ");
        SendClientMessage(playerid, C_GREEN, " - /w(eap)(on) [weapon name] > Gives you a weapon of your choice ");
        SendClientMessage(playerid, C_RED, " - /(v/w)names > Gives you a link where to check the weapon/vehicle names ");
        SendClientMessage(playerid, C_GREEN, " - This filterscript is made by Wesley221! ");
        return 1;
}
 
/* Name help */
COMMAND:vnames(playerid, cmdtext[])
                                return SendClientMessage(playerid, C_GREEN, " ** Please visit \"http://wiki.sa-mp.com/wiki/Vehicle_Model_ID_List\" for all the vehicle names!");
COMMAND:wnames(playerid, cmdtext[])
                                return SendClientMessage(playerid, C_GREEN, " ** Please visit \"http://wiki.sa-mp.com/wiki/Weapons\" for al the weapon names!");
/* Spawn vehicle & weapon */
COMMAND:veh(playerid, cmdtext[])
                                return cmd_v(playerid, cmdtext);
COMMAND:vehicle(playerid, cmdtext[])
                                return cmd_v(playerid, cmdtext);
COMMAND:weap(playerid, cmdtext[])
                                return cmd_w(playerid, cmdtext);
COMMAND:weapon(playerid, cmdtext[])
                                return cmd_w(playerid, cmdtext);
 
//==============================================================================
//
//Stocks
//
//==============================================================================
stock GetVehicleModelID(vehiclename[])
{
        for(new i = 0; i < 211; i++)
        {
                if(strfind(aVehicleNames[i], vehiclename, true) != -1)
                return i + 400;
        }
        return -1;
}
 
stock GetWeaponID(weaponname[])
{
        for(new i = 0; i < 45; i++)
        {
            if(strfind(aWeaponNames[i], weaponname, true) != -1)
            return i;
        }
        return -1;
}
 
 
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
        new Float:a;
 
        GetPlayerPos(playerid, x2, y2, a);
        GetPlayerFacingAngle(playerid, a);
 
        if(GetPlayerVehicleID(playerid))
        {
                GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
        }
 
        x2 += (distance * floatsin(-a, degrees));
        y2 += (distance * floatcos(-a, degrees));
}
 
//==============================================================================
//
// Filterscript Init/Exit
//
//==============================================================================
public OnFilterScriptInit(){
        print("|_| VehicleSpawner |_|");
        print("|_| VehicleSpawner --> Loaded |_|");
        print("|_| Do NOT remove the credits |_|");
        return 1;
}
public OnFilterScriptExit(){
        print("|_| VehicleSpawner |_|");
        print("|_| VehicleSpawner --> UnLoaded |_|");
        print("|_| Do NOT remove the credits |_|");
        return 1;
}
 
//==============================================================================
//
// Random messages
//
//==============================================================================
#if USE_RMESSAGE == true
forward RandomMessage();
public RandomMessage()
{
        new string[128];
        format(string, sizeof string, MESSAGE3, PAY);
        new rand = random(5);
        if(rand == 0) return rand +1;
        switch(rand)
        {
                case 1: SendClientMessageToAll(C_GREEN, MESSAGE1);
                case 2: SendClientMessageToAll(C_GREEN, MESSAGE2);
                case 3: SendClientMessageToAll(C_GREEN, string);
                case 4: SendClientMessageToAll(C_GREEN, MESSAGE4);
                case 5: SendClientMessageToAll(C_GREEN, MESSAGE5);
        }
        return 1;
}
 
public OnPlayerConnect(playerid)
{
        SetTimer("RandomMessage", 60000, true);
        return 1;
}
#endif