[CMD] GiveMyGunTo by Garciat - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [CMD] GiveMyGunTo by Garciat (
/showthread.php?tid=20596)
[CMD] GiveMyGunTo by Garciat -
Garciat - 29.12.2007
[CMD] GiveMyGunTo 1.0
Gives your current weapon to a fellow player!
Commands:
- /givemygunto [playerid] - Gives your current weapon to player #[id]
Inspired by
exora's idea.
Script
Код:
if(strcmp(cmd, "/givemygunto", true) == 0) {
new tmp[256];
new string[256];
new weaponname[65], playername[MAX_PLAYER_NAME], player2name[MAX_PLAYER_NAME];
new playermsg[256], player2msg[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "Usage: /givemygunto [playerid]");
return 1;
}
new player2id = strval(tmp);
if(IsPlayerConnected(player2id))
{
if(player2id==playerid)
{
SendClientMessage(playerid, COLOR_RED, "You can't use your own ID");
return 1;
}
else
{
new weaponid = GetPlayerWeapon(playerid);
new weaponammo;
if(weaponid == 0)
{
SendClientMessage(playerid, COLOR_RED, "You're not holding a weapon");
return 1;
}
else
{
new weapons[13][2];
for(new i;i<13;i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
if(weapons[i][0]==weaponid) weaponammo=weapons[i][1];
}
ResetPlayerWeapons(playerid);
for(new i;i<13;i++) if(weapons[i][0]!=weaponid) GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
GivePlayerWeapon(player2id, weaponid, weaponammo);
GetWeaponName(weaponid, weaponname, 64);
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(player2id, player2name, sizeof(player2name));
format(playermsg, 255, "You gave your %s to %s(%d)", weaponname, player2name, player2id);
SendClientMessage(playerid, COLOR_YELLOW, playermsg);
format(player2msg, 255, "You recived a %s from %s(%d)", weaponname, playername, playerid);
SendClientMessage(player2id, COLOR_YELLOW, player2msg);
}
}
}
else
{
format(string, sizeof(string), "(%d) is not an active player", player2id);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
If you want any custom settings, PM me or EMAIL me.
Re: [CMD] GiveMyGunTo by Garciat -
Rks25 - 29.12.2007
Why don't you host this in the Usefull Commands topic?
Anyway, nice work !
Rkss
Re: [CMD] GiveMyGunTo by Garciat -
Garciat - 29.12.2007
Quote:
Originally Posted by Rks25
Why don't you host this in the Usefull Commands topic?
Anyway, nice work !
Rkss
|
Thanks. I'm "new" to the forum, I've never heard of a useful commands topic. A link might help.
Re: [CMD] GiveMyGunTo by Garciat -
cmg4life - 29.12.2007
Nice Commands Garciat, you should make a topic Garciat CMDS :P
http://forum.sa-mp.com/index.php?topic=2868.0 > Useful commands but is kinda big
Re: [CMD] GiveMyGunTo by Garciat -
SinisterCrime- - 29.12.2007
Good stuff
Re: [CMD] GiveMyGunTo by Garciat -
Garciat - 29.12.2007
Quote:
Originally Posted by SinisterCrime-
Good stuff 
|
Thank you. If you have good ideas, I can script them for you or
anyone.
Re: [CMD] GiveMyGunTo by Garciat -
woot - 29.12.2007
Thanks, man
Re: [CMD] GiveMyGunTo by Garciat -
SinisterCrime- - 29.12.2007
How about.. Scripting
A person uses /takeweapon [playerid] and the player id the person is takeing it from.. Has to confirm it.. If he comfirms it it will go to the person who asked for it
Re: [CMD] GiveMyGunTo by Garciat -
woot - 29.12.2007
Lol, weird
Код:
C:\DOKUME~1\MANUEL~1\Desktop\GTASTU~1\SAMP02~1.WIN\GAMEMO~1\training.pwn(121) : error 017: undefined symbol "idx"
tmp = strtok(cmdtext, idx);
xD
Re: [CMD] GiveMyGunTo by Garciat -
SinisterCrime- - 29.12.2007
Do Top of script
new idx;
Or put it under
OnPlayerCommandText