SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/07/2020, 12:13 PM   #1
AngeloMk
Little Clucker
 
AngeloMk's Avatar
 
Join Date: May 2019
Location: Venezuela
Posts: 30
Reputation: 6
Default Cant you make a /weapon and /vehicle Command with ZCMD?

I need a script like:

/weapon [Weapon ID] [Ammo]
/vehicle [Vehicle ID]

but with ZCMD please, compact command for optimize the gamemode.
__________________
____________________________________________

💎Servidor Oficial en Espaņol.
____________________________________________
🌐 Website: https://www.drugsliferp.glitch.me/
📢 Discord: https://discord.gg/CQMN6fP
____________________________________________
AngeloMk is offline   Reply With Quote
Old 01/07/2020, 12:32 PM   #2
SharpenBlade
Big Clucker
 
Join Date: May 2020
Posts: 175
Reputation: 23
Default Re: Cant you make a /weapon and /vehicle Command with ZCMD?

PHP Code:
CMD:weapon(playeridparams[])
{
    new 
weaponidammo;
    if(
sscanf(params"dd"weaponidammo)) return SendClientMessage(playerid, -1"Usage: weapon <weaponid> <ammo>");

    if(
ammo <= || ammo 9999) return SendClientMessage(playerid, -1"Invalid ammo value!);

    new WeaponID, string[128];
    if(IsNumeric(weaponid)) WeaponID = strval( weaponid );
    else WeaponID = GetWeaponIDFromName(weaponid);
    if(!IsValidWeapon(WeaponID)) return SendClientMessage(playerid, -1, "
Invalid weapon ID!");
    new WeaponName[32];
    GetWeaponName(WeaponID, WeaponName, 32);
    GivePlayerWeapon(playerid, WeaponID, ammo);
    format(string, sizeof(string), "
You have received %s(%dwith %d rounds of amoo.", WeaponName, WeaponID, ammo);
    SendClientMessage(playerid, -1, string);
    return 1;
}

stock IsNumeric( string[ ] )
{
    for ( new i = 0, j = strlen( string ); i < j; i++ )
    {
        if( string[ i ] > '9' || string[ i ] < '0' )
            return false;
    }
    return true;
}

stock GetWeaponIDFromName( WeaponName[ ] )
{
    if( strfind( "
molotov", WeaponName, true ) != -1 ) return 18;
    for ( new i = 0; i <= 46; i++ )
    {
        switch( i )
        {
            case 0,19,20,21,44,45: continue;
            default:
            {
                new name[ 32 ];
                GetWeaponName( i, name, 32 );
                if( strfind( name, WeaponName, true ) != -1 ) return i;
            }
        }
    }
    return -1;
}

stock IsValidWeapon( weaponid )
{
    if ( weaponid > 0 && weaponid < 19 || weaponid > 21 && weaponid < 47 ) return true;
    return false;
}

CMD:vehicle(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid)) return 1;

    new vID;
    if(sscanf(params, "
d", vID)) return SendClientMessage(playerid, -1, "Usage: /vehicle <id>");

    new CarModel;
    if(IsNumeric(vID)) CarModel = strval(vID); //if my input is numeric will set the value
    else CarModel = GetVehicleModelIDFromName(vID); //if i type a vehicle name it will search for id

    if(CarModel < 400 || CarModel > 611) return SendClientMessage(playerid, -1, "
Invalid vehicle model/name!");
    new carid, pPos[3];
    GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
    carid = CreateVehicle(CarModel, pPos[0], pPos[1], pPos[2], 1, 1, -1);
    SetVehicleVirtualWorld(carid, GetPlayerVirtualWorld(playerid));
    LinkVehicleToInterior(carid, GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, carid, 0);
    return 1;
}
stock GetVehicleModelIDFromName( vname[ ] )
{
    for ( new i = 0; i < 211; i++ )
        if( strfind( VehName[ i ], vname, true ) != -1 ) // replace VehName with your storing vehicle names function
            return i + 400;

    return -1;

Also, this is not a script request section. You can take the above code as an example.
SharpenBlade 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
How make a /w2 (weapon give command) with ZCMD AngeloMk Scripting Help 1 19/06/2020 04:33 PM
[Tutorial] How to make a Simple Weapon Command with Ammo kirostar Tutorials 5 03/07/2014 02:34 AM
How do I make this command to zcmd? NeyMar96 Help Archive 3 24/07/2011 11:36 PM
How to make command ''pm'' trough zcmd [WSF]ThA_Devil Help Archive 3 31/10/2010 07:56 AM
How can i make a weapon command Battlaman Help Archive 3 18/05/2009 08:04 PM


All times are GMT. The time now is 05:57 AM.


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