SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   How to give weapons to All with one CMD? (https://forum.sa-mp.com/showthread.php?t=466061)

MAFIAWARS 25/09/2013 07:20 PM

How to give weapons to All with one CMD?
 
Can any one give me that Command so I can give players Weapons in just One Command ?
Like it:

/giveweapon <playerid> <weaponid> <ammo>

And Also /setskin Command to Set the Player Skin like that:

/setskin <playerid> <skinid>

Thanks in Advance.

DanishHaq 25/09/2013 07:28 PM

Re: How to give weapons to All with one CMD?
 
pawn Code:
CMD:giveweapon(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_WHITE, "Invalid admin level.");
    new giveplayerid, weaponid, ammo;
    if(sscanf(params, "udd", giveplayerid, weaponid, ammo)) return SendClientMessage(playerid, COLOR_WHITE, "Correct usage: /giveweapon [playerid/name] [weaponid] [ammo]");
    if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid player ID");
    GivePlayerWeapon(giveplayerid, weaponid, ammo);
    return 1;
}

CMD:setskin(playerid, params[], help)
{
    if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_WHITE, "Invalid admin level.");
    new giveplayerid, skinid;
    if(sscanf(params, "ud", giveplayerid, skinid)) return SendClientMessage(playerid, COLOR_WHITE, "Correct usage: /setskin [playerid/name] [skinid]");
    if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid player ID");
    SetPlayerSkin(giveplayerid, skinid);
    return 1;
}

ZCMD & sscanf

MAFIAWARS 26/09/2013 07:25 AM

Re: How to give weapons to All with one CMD?
 
Thanks Man !

But When I setskin of some player his running or moving style change while he has weapons, why??

And Also tell me How to Give weapons to All with just one Command, like /giveweapontoall <weaponid> <ammo>

MAFIAWARS 26/09/2013 08:04 AM

Re: How to give weapons to All with one CMD?
 
Made /disarm Command Successfully.
But, I wrote SendClientMessage to targetid...

pawn Code:
SendClientMessage(targetid, COLOR_RED1, "%d has reseted your Weapons !");

It is working Fine But Not Showing Admin Name But showing Numbers lol.

http://www.wsrpg.com/upload/images/-1380182941.png

SAMProductions 26/09/2013 08:10 AM

Re: How to give weapons to All with one CMD?
 
Try This One:

pawn Code:
new playerName[24];
new string[128];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s (ID: %d) has reseted your Weapons !", playerName, playerid);
SendClientMessage(targetid, COLOR_RED1, string);

or

pawn Code:
SendClientMessage(playerid, COLOR_RED1, "%s has reseted your Weapons !")

Anyways,

%d is "Inserts an integer (whole) number"

so use, %s

%s is Inserts a string.

iZN 26/09/2013 08:16 AM

Re: How to give weapons to All with one CMD?
 
Let me correct you abit. %d specifier is for decimal values. %i is for integer. Use format to use specifier, it will work like this:
pawn Code:
new PlayerName[24], str_[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(str_, sizeof(str_), "%s(%i) has reseted your weapons!", PlayerName, playerid);
SendClientMessage(targetid, COLOR_RED1, str_);


All times are GMT. The time now is 02:14 AM.

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