SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/05/2016, 05:14 PM   #1
Digii
Little Clucker
 
Join Date: Jan 2016
Posts: 34
Reputation: 0
Question vehicle slap

Hello everyone, I was thinking to make a command such as /slapcar but I didn't succed and I was thinking if anyone of you can help me to make this command, btw I'm using zcmd.

Sorry for my rubbish english.
Thank you very much boyz!!
Digii is offline   Reply With Quote
Old 14/05/2016, 05:24 PM   #2
Skimmer
Gangsta
 
Skimmer's Avatar
 
Join Date: Oct 2012
Location: Germany
Posts: 484
Reputation: 56
Default Re: vehicle slap

First define SLAP_HEIGHT top of your code. You can change the value according to your taste.
pawn Code:
#define SLAP_HEIGHT 10

And here's the command.
pawn Code:
COMMAND:slapcar(playerid, params[])
{
    new vehicleid;

    if(sscanf(params, "i", vehicleid))
        return SendClientMessage(playerid, -1, "USAGE: /slapcar <vehicleid>");

    if(vehicleid == INVALID_VEHICLE_ID)
        return SendClientMessage(playerid, -1, "Invalid Vehicle ID!");

    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    SetVehiclePos(vehicleid, x, y, z + SLAP_HEIGHT);
    return 1;
}
Skimmer is offline   Reply With Quote
Old 14/05/2016, 05:28 PM   #3
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: vehicle slap

Or :
PHP Code:
COMMAND:slapcar(playeridparams[])
{
    new 
vehicleidheight;

    if(
sscanf(params"ii"vehicleidheight))
        return 
SendClientMessage(playerid, -1"USAGE: /slapcar <vehicleid> <height>");

    if(
vehicleid == INVALID_VEHICLE_ID)
        return 
SendClientMessage(playerid, -1"Invalid Vehicle ID!");

    new 
Float:xFloat:yFloat:z;
    
GetVehiclePos(vehicleidxyz);
    
SetVehiclePos(vehicleidxyheight);
    return 
1;

No?
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 14/05/2016, 05:34 PM   #4
Digii
Little Clucker
 
Join Date: Jan 2016
Posts: 34
Reputation: 0
Default Re: vehicle slap

Danke Skimmer and Dayrion, you helped me alot, thank you again brothers!!

SOLVED!
Digii is offline   Reply With Quote
Old 14/05/2016, 05:34 PM   #5
Sjn
Huge Clucker
 
Join Date: Jul 2015
Location: Nepal
Posts: 349
Reputation: 50
Default Re: vehicle slap

A small correction for the answers posted above, the height should be a Float value. If it's an integer, the compiler will convert it into a float value which may cause a slight of difference while compiling. (From what I read)
Sjn is offline   Reply With Quote
Old 14/05/2016, 05:37 PM   #6
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 414
Default Re: vehicle slap

From a long long time ago I remember that if you want to "slap" the vehicle higher into the air and have it continue moving in the direction that it was moving before, you should save the vehicle's velocity before calling SetVehiclePos and re-apply it after calling SetVehiclePos.

The functions for retrieving and setting the velocity of a vehicle are:
GetVehicleVelocity
SetVehicleVelocity
AndreT is offline   Reply With Quote
Old 14/05/2016, 05:43 PM   #7
Digii
Little Clucker
 
Join Date: Jan 2016
Posts: 34
Reputation: 0
Default Re: vehicle slap

So how my command should look like?
Digii is offline   Reply With Quote
Old 14/05/2016, 05:52 PM   #8
Skimmer
Gangsta
 
Skimmer's Avatar
 
Join Date: Oct 2012
Location: Germany
Posts: 484
Reputation: 56
Default Re: vehicle slap

@AndreT has right. But I wanted to give him a simple code.

@Digii. AndreT means with my code above, when a players drives a car and you slap the vehicle that he drives it gets stopped. But if you don't want to stop it, you can use this code.

pawn Code:
COMMAND:slapcar(playerid, params[])
{
    new vehicleid;

    if(sscanf(params, "i", vehicleid))
        return SendClientMessage(playerid, -1, "USAGE: /slapcar <vehicleid>");

    if(vehicleid == INVALID_VEHICLE_ID)
        return SendClientMessage(playerid, -1, "Invalid Vehicle ID!");

    new Float:x, Float:y, Float:z,
        Float:vx, Float:vy, Float:vz;

    GetVehiclePos(vehicleid, x, y, z);
    GetVehicleVelocity(vehicleid, vx, vy, vz);

    SetVehiclePos(vehicleid, x, y, z + SLAP_HEIGHT);
    SetVehicleVelocity(vehicleid, vx, vy, vz);
    return 1;
}
Skimmer is offline   Reply With Quote
Old 14/05/2016, 06:02 PM   #9
Digii
Little Clucker
 
Join Date: Jan 2016
Posts: 34
Reputation: 0
Default Re: vehicle slap

I'm actually very surprised because of your patience and help you guys are awesome, I can't actually believe that you brothers gave me the full command ( I'm emotional thank you again my brothers for helping me.
All of you are awesome boys!!
Digii is offline   Reply With Quote
Old 14/05/2016, 07:20 PM   #10
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: vehicle slap

Yea, I'd go for the velocity portion, imagine their faces when they get thrown up a few feet in one motion rather than being "put" up a few feet...

Not saying these portions of code aren't good, it's just all about aesthetics for me.
Sew_Sumi 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
Slap SaiyanZ Scripting Help 8 25/04/2016 03:27 PM
slap Deny1 Scripting Help 14 31/01/2016 01:17 PM
[Help]Slap CMD xRandomGuy Scripting Help 12 01/10/2013 05:28 PM
Help with slap cmd diego_p11 Scripting Help 1 06/01/2013 12:53 AM
a Vehicle slap ihatetn931 Help Archive 5 20/10/2010 08:38 AM


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


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