custom car weps?

Started by MEGAMIND, Jun 03, 2018, 08:10 PM

Previous topic - Next topic

MEGAMIND

hellow everybody i have a weird question, well i made a destruction rally game mode with cars having tank fire rocket inside them,

what i ment to say was when u fire from a rhino a missile fires so i did same with the cars so problem occured that i had a car duel with couple of freinds none of us were able to bomb each other or destroy ech other any help regarding my problem
Thanks,

ik once A great vcmp scripter Doomkiller made that type of thing but no one could have ever acheived that i tried my best i can destroy normal cars with no one in them but not the cars having players inside them, and thats the place when we couldnt destroy each other

i hope i may get positive replies...

a clip of my game mode
https://www.youtube.com/watch?v=yvOz78VDRfc#

one more thing y do we have this <extraflags>0</extraflags> ik its something fr special abilitites so i replaced it with rihinos flags, thats how i was able to fire rokcets but still the problem is what i said above ,so is there any way to add a weapon to a vehicle? help pls

DizzasTeR

I didn't use custom vehicle flags, I made it completely client + server sided. I basically calculated all the stuff on client via raytraces, time periods and velocities by checking distances etc, then sent the information back, to create a rocket object, move it with the speed relative to the distance of the hitting object (buildings, players/vehicles) and then create an explosion at the end.

It was achieved in 3 stages, initial trigger to client, calculations on client, results back to server to perform the shoot.

MEGAMIND

#2
now thats too much beyond my limits :P
anyone elsae pls ^^ actually dooms stuff and skills r too pro and beyong my limits or OUR limits so anyone out there got a solution to this or have tried these before....!

Xmair

#3
Quote from: MEGAMIND on Jun 03, 2018, 08:51 PMnow thats too much beyond my limits :P
anyone elsae pls ^^ actually dooms stuff and skills r too pro and beyong my limits or OUR limits so anyone out there got a solution to this or have tried these before....!
Make a keybind, when that key is pressed (do all the checks and), send a stream to the client, RayTrace(veh.Pos, (some math here or just simply veh.Pos.y + 20 ), RAY_BUILDING || RAY_PED || RAY_VEHICLE || RAY_OBJECT);, on another line, check if RayTrace.Collided( ), if it is true then check RayTrace.Entity( ), it can be a vehicle, object, or anything but not null then send a stream of the entity's position to server side and create a rocket object which .MoveTo that position in x amount of time and then create a timer with the same x amount of time which has a statement with CreateExplosion with playerCaused being the player who shot the rocket.


Quote from: MEGAMIND on Jun 03, 2018, 08:10 PMik once A great vcmp scripter Doomkiller made that type of thing but no one could have ever acheived
He isn't the only one tho he told me how to do this a long time ago. (also fuk u doom im jelly)

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MEGAMIND

#4
http://forum.vc-mp.org/?topic=1131.msg7545#msg7545 did doom helped?

+ i found this to from sometopic

function ShootRocket(player)
{
    local PosToCreate, HINSTANCE, WINAPI = "~"; //Init variables
    null == true ? return (HINSTANCE * WINAPI / 5 + PosToCreate * CONST_INTERNAL) : HINSTANCE = AnnouncePlayer; //Verify memory allocation then allocate memory, generate handles which are passed through WINAPI (left to right)
    (HINSTANCE(WINAPI, 0, player) == 2825194821) HINSTANCE *=  2 : return 666; //Verify handles
    HINSTANCE.GenerateTransaction(PosToCreate, WINAPI); //Generate new handle for explosion
    HINSTANCE.Explosion.Initialize(HANDLE); //Execute the handle to generate explosion
    return null; //Return null
}

&
local rayTrace = RayTrace( World.FindLocalPlayer( ).Position, aimPosFewMilesAway, ( OBJ_PLAYER | OBJ_VEHICLE | OBJ_BUILDING ) );
if ( rayTrace.Collided( ) ) sendStreamToServer( );

MEGAMIND

any ideas guysss.....?

MEGAMIND

#6
*Bump* topic still not solved :(

something like this was required Doomkiller awsome thing
https://www.youtube.com/watch?v=wsKNpEeGkMQ#
;P

MEGAMIND

*bump*

any body? with knowledge like Dooms have tried this stuff before?

DizzasTeR

We already told you the method, the only thing left is to code it, it isn't that hard, will just take you a couple of tries, I lost all my scripts of my multigamemode so I can't provide you the code anymore.

MEGAMIND


Saiyan Attack

#10
client-side :-
enum Identity {
Shoot = 0x01,
};

function Server::ServerData(stream)
{
local stbyte = stream.ReadByte();
switch(stbyte) {
case Identity.Shoot:
local start = stream.ReadString( ), end = stream.ReadString( );
local startpoint = split(start,"\n"), endpoint = split(end,"\n");
local sx = startpoint[0], sy = startpoint[1], sz = startpoint[2], ex = endpoint[0], ey = endpoint[1], ez = endpoint[2];
Shooter( Vector( sx.tofloat(), sy.tofloat(), sz.tofloat() ), Vector( ex.tofloat(), ey.tofloat(), ez.tofloat() ) );
break;
}
}

function Shooter( startpos, endpos )
{
local detector = RayTrace( startpos, endpos, (RAY_BUILDING | RAY_PED | RAY_VEHICLE | RAY_OBJECT));
if ( detector.Collided == true && detector.Entity != null ) {
local hitpoint = detector.Position;
local stream = Stream( );
stream.WriteByte( Identity.Shoot );
stream.WriteString(hitpoint.X+"\n"+hitpoint.Y+"\n"+hitpoint.Z);
Server.SendData( stream );
}
}

Saiyan Attack

#11
fixed now we can shoot through any vehicle ... here is the working code :-
Serverside :-
enum Identity {
Shoot = 0x01,
};

function onScriptLoad()
{
CTRL <- BindKey(true,0x11,0,0);
}

function onKeyDown(player, key)
{
switch(key) {
case CTRL:
if(player.Vehicle) sendClientData(player, "Shoot");
break;
}
}

function onClientScriptData(player)
{
local client = Stream(), stbyte = client.ReadByte();
switch(stbyte) {
case Identity.Shoot:
local hitpoint = client.ReadString();
local coords = split(hitpoint,"\n"), x = coords[0], y = coords[1], z = coords[2];
CreateExplosion(1, 7,Vector(x.tofloat(), y.tofloat(), z.tofloat()), player.ID, true);
break;
}
}

function sendClientData(player, data)
{
switch(data) {
case "Shoot":
local veh = player.Vehicle, client = Stream();
client.StartWrite();
client.WriteByte(Identity.Shoot);
local startpoint = GetForwardPoint( veh.Pos, 6.0, GetRadiansAngle(veh.Angle) ), endpoint = GetForwardPoint(veh.Pos, 100.0, GetRadiansAngle(veh.Angle));
client.WriteString(startpoint);
client.WriteString(endpoint);
client.SendStream(player);
break;
}
}

function GetRadiansAngle(Rotation)
{
 local angle;
 angle = ::asin( Rotation.z ) * -2;
 return Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}

function GetForwardPoint( pos, gap, angle )
{
  local x = pos.x + 1.0 * cos(angle) - gap * sin(angle)
  local y = pos.y + 1.0 * sin(angle) + gap * cos(angle);
  return  x+"\n"+y+"\n"+pos.z;
}



and now all you need to generate rocket by CreateObject!