SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 04/12/2019, 09:38 PM   #1
InYourDreams
Little Clucker
 
Join Date: Oct 2019
Posts: 39
Reputation: 14
Default Snow Plowing Vehicles / AttachObjectToVehicle



Hello guys! Today im presenting to you a simple script. Its about plowing vehicles in samp. I added snow plow to few cars:
  • Dune
  • Yosemite
  • Bobcat
  • Sadler
  • Rancher

I know this is really simple Filescript but i also know that there is people that dont know how to add simple object and attach it to vehicle. You can use it for your servers etc.

You can see how that looks in my video on youtube channel. Just click on video link below.

VIDEO LINK: https://youtu.be/vWCISlhJQxI


DOWNLOAD LINK: https://pastebin.com/whZj2XJs

If you wanna to see more cars with snow plow, leave a comment here and ill make sure to add snow plow to them and to make version 2 of this vehicles, also i tried to add samp particle effects on both sides of snow plow to look even more realistic like vehicle is really plowing a snow, maybe i will add that in version 2 also. Hope you will like my video and subscribe for more stuff like this. Thank you!
InYourDreams is offline   Reply With Quote
Old 05/12/2019, 01:10 AM   #2
l0gic
Little Clucker
 
Join Date: Aug 2019
Posts: 7
Reputation: 0
Default Re: Snow Plowing Vehicles / AttachObjectToVehicle

This code is useless, it's very hard to implement it with gamemode and please comment your code so others can understand what sign / object is attached to what vehicle.
And start using github for such includes / projects, so you can make simple future updates.
Also attached objects must be destroyed or they will be spawned at world zero point.
Aaand filterscripts are really bad for gamemodes anyway, because it's compilcated to access filterscript data from main gamemode and so everything is better when it's built like include.
It would make total gamemode making process faster, because you can easily install and update fast with sampctl.
PHP Code:
//Vehicles plow objects ids are stored here
new aVehiclePlowObject[MAX_VEHICLES];

/**
Attach plow object to vehicle when it has valid modelid
vehicleID = vehicle id where we want to attach object
return = returns object id so it can be deleted later
*/
stock attachPlowToVehicle(vehicleID){
    new 
modelID GetVehicleModel(vehicleID);
    
//checks if model id is valid
    
if(modelID != 573 && modelID != 554 && modelID != 422 && modelID != 543 && modelID != 505)
        return 
0;
    
//creates plow object
    
new objectID CreateDynamicObject(196010.00.0, -1000.00.00.00.0, -1, -1, -1300.0300.0);
    
//dune - off road
    
if(modelID == 573){
        
SetDynamicObjectMaterial(objectID0, -1"none""none", -10092544);
        
AttachDynamicObjectToVehicle(objectIDvehicleID0.0003.474, -1.09713.7990.000180.000);
    }
    
//yosemite - industrial
    
if(modelID == 554){
        
SetDynamicObjectMaterial(objectID0, -1"none""none", -1);
        
AttachDynamicObjectToVehicle(objectIDvehicleID0.0002.844, -0.4929.7990.000180.000);
    }
    
//bobcat - industrial
    
if(modelID == 422){
        
AttachDynamicObjectToVehicle(objectIDvehicleID0.0002.561, -0.5400.0000.000180.000);
    }
    
//sadler - industrial
    
if(modelID == 543){
        
AttachDynamicObjectToVehicle(objectIDvehicleID, -0.0902.590, -0.3700.0000.000180.000);
    }
    
//rancher lure - off road
    
if(modelID == 505){
        
AttachDynamicObjectToVehicle(objectIDvehicleID, -0.0402.886, -0.6476.8990.000180.000);
    }
    return 
objectID;
}

public 
OnVehicleDeath(vehicleidkillerid){
    
//Checks if vehicle has plow object attached and destroies it
    
if(aVehiclePlowObject[vehicleid] > 0){
        
DestroyDynamicObject(aVehiclePlowObject[vehicleid]);
        
aVehiclePlowObject[vehicleid] = 0;
    }
    return 
1;
}

public 
OnGameModeInit(){
    
//TESTING
    
new vehicleID CreateVehicle(5730.00.00.00.01130000);
    
aVehiclePlowObject[vehicleID] = attachPlowToVehicle(vehicleID);

    
vehicleID CreateVehicle(5540.00.00.00.01130000);
    
aVehiclePlowObject[vehicleID] = attachPlowToVehicle(vehicleID);
    return 
1;

l0gic is offline   Reply With Quote
Old 05/12/2019, 01:47 AM   #3
InYourDreams
Little Clucker
 
Join Date: Oct 2019
Posts: 39
Reputation: 14
Default Re: Snow Plowing Vehicles / AttachObjectToVehicle

Logic thank you very much! Im not good at all with scripting, i thought exported fs from texture studio would be enough for people to use it. Glad you helped also. Thanks again!
InYourDreams is offline   Reply With Quote
Old 05/12/2019, 02:21 AM   #4
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,899
Reputation: 1321
Default Re: Snow Plowing Vehicles / AttachObjectToVehicle

The TS export code was designed to create a FS that you could just load and unload. In 5 minutes a exported script could easily be updated to be an include for a gamemode.

I would recommend that if you release a vehicle to also provide the Texture Studio map, exported vehicle fs and your own function like attachPlowToVehicle(vehicleID).

Code:
public OnVehicleDeath(vehicleid, killerid){
    //Checks if vehicle has plow object attached and destroies it
    if(aVehiclePlowObject[vehicleid] > 0){
        DestroyDynamicObject(aVehiclePlowObject[vehicleid]);
        aVehiclePlowObject[vehicleid] = 0;
    }
    return 1;
}
Why bother destroying the object? It will be re-attached once the vehicle respawns particularly if you have a lot of objects attached to a single vehicle. I could understand you might want to do that then it is a case of extending functionality. A "clean vehicle" flag? Delete any objects.
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Snow Brys Scripting Help 1 21/12/2014 12:07 PM
Problem with plowing Dusan01 Scripting Help 0 23/05/2013 03:54 PM
[FilterScript] Snow ! xTouglix Filterscripts 24 14/12/2012 02:48 PM
Snow everywhere RBTDM Scripting Help 9 12/12/2011 07:45 PM
How can i make Snow come in samp 0.2? [Pixel^ Falling snow] hardstop Help Archive 6 11/11/2009 09:50 AM


All times are GMT. The time now is 08:44 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.