Easy Question about /GiveWeapon
#1

Hello i have question about Give weapon
that only Admin can do it like
admin Rcon
/Give weapon [playerID] [WeaponID] [Ammo]
how make it thanks
Reply
#2

you want only rcon admins to /give weapon?
Reply
#3

add this under OnPlayerCommandText
pawn Код:
dcmd_giveweapon(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"giveweapon")) {
        new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index),tmp2 = strtok(params,Index),tmp3 = strtok(params,Index);
        if(!strlen(tmp)||!strlen(tmp2)||!strlen(tmp3)||!IsNumeric(tmp3)||!(strval(tmp3) <= 0 || strval(tmp3) <= 10000)) return SendClientMessage(playerid,red,"Syntax Error: \"/GIVEWEAPON <NICK OR ID> <WEAPON NAME | ID> <1-10,000>\".");
        new id,id2; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp); if(!IsNumeric(tmp2)) id2 = ReturnWeaponID(tmp2); else id2 = strval(tmp2);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID) {
            if(id2==-1||id2==19||id2==20||id2==21||id2==0||id2==44||id2==45) return SendClientMessage(playerid,red,"ERROR: You have selected an invalid weapon ID.");
            SendCommandMessageToAdmins(playerid,"GIVEWEAPON");
            new string[256],name[24],ActionName[24],WeaponName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24); GetWeaponName(id2,WeaponName,24); if(id2 == 18) WeaponName = "Molotov";
            if(id != playerid) { format(string,256,"Administrator \"%s\" has given you %d %s.",name,strval(tmp3),WeaponName); SendClientMessage(id,yellow,string); format(string,256,"You have given \"%s\" %d %s.",ActionName,strval(tmp3),WeaponName); SendClientMessage(playerid,yellow,string); }
            else { format(string,256,"You have given yourself %d %s.",strval(tmp3),WeaponName); SendClientMessage(playerid,yellow,string); }
            return GivePlayerWeapon(id,id2,strval(tmp3));
        } else return SendClientMessage(playerid,red,"ERROR: You can not give a disconnected player a weapon.");
    } else return SendLevelErrorMessage(playerid,"giveweapon");
}
and
pawn Код:
{
    dcmd(giveweapon,10,cmdtext);
        return 0;
}
above dcmd_giveweapon
Reply
#4

Yes
But all Weapons ID
Reply
#5

This:

PHP код:
    if(strcmp(cmd"/giveweapon"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /giveweapon[playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
                return 
1;
            }
            new 
playa;
            new 
gun;
            new 
ammo;
            
playa ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            
gun strval(tmp);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD1"USAGE: /giveweapon [playerid/PartOfName] [weaponid] [ammo]");
                
SendClientMessage(playeridCOLOR_GRAD4"3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
                
SendClientMessage(playeridCOLOR_GRAD3"24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
                return 
1;
            }
            if(
gun 1||gun 46||gun==27||gun==1||gun==2||gun==9||gun==19||gun==20||gun==21||gun==36||gun==39||gun==40||gun==44||gun==45)
            { 
SendClientMessage(playeridCOLOR_GRAD1"   wrong WeaponID!"); return 1; }
            
tmp strtok(cmdtextidx);
            
ammo strval(tmp);
            if(
ammo <1||ammo 999)
            { 
SendClientMessage(playeridCOLOR_GRAD1"   dont go below 1 or above 999 bullets!"); return 1; }
            if(!
IsPlayerAdmin(playerid))            {
                if(
IsPlayerConnected(playa))
                {
                    if(
playa != INVALID_PLAYER_ID)
                    {
                        
GivePlayerWeapon(playagunammo);
                        
GetPlayerName(playagiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
format(string256"News: %s has given %s gun id %d."giveplayer,sendername,gun);
                        
ABroadCast(COLOR_YELLOW,string,1);
                    }
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GRAD1"   you are not authorized to use that command!");
            }
        }
        return 
1;
    } 
EDITED!
Reply
#6

Код:
dcmd_giveweapon(playerid,params[]) {
I'm Using ZCMD
Код:
CMD:give weapon(playerid, params[])
i'm tryed add your Script
To my pwno
Код:
dcmd_giveweapon(playerid,params[]) {
	if(IsPlayerCommandLevel(playerid,"giveweapon")) {
	    new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index),tmp2 = strtok(params,Index),tmp3 = strtok(params,Index);
	    if(!strlen(tmp)||!strlen(tmp2)||!strlen(tmp3)||!IsNumeric(tmp3)||!(strval(tmp3) <= 0 || strval(tmp3) <= 10000)) return SendClientMessage(playerid,red,"Syntax Error: \"/GIVEWEAPON <NICK OR ID> <WEAPON NAME | ID> <1-10,000>\".");
		new id,id2; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp); if(!IsNumeric(tmp2)) id2 = ReturnWeaponID(tmp2); else id2 = strval(tmp2);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID) {
        	if(id2==-1||id2==19||id2==20||id2==21||id2==0||id2==44||id2==45) return SendClientMessage(playerid,red,"ERROR: You have selected an invalid weapon ID.");
            SendCommandMessageToAdmins(playerid,"GIVEWEAPON");
			new string[256],name[24],ActionName[24],WeaponName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24); GetWeaponName(id2,WeaponName,24); if(id2 == 18) WeaponName = "Molotov";
            if(id != playerid) { format(string,256,"Administrator \"%s\" has given you %d %s.",name,strval(tmp3),WeaponName); SendClientMessage(id,yellow,string); format(string,256,"You have given \"%s\" %d %s.",ActionName,strval(tmp3),WeaponName); SendClientMessage(playerid,yellow,string); }
			else { format(string,256,"You have given yourself %d %s.",strval(tmp3),WeaponName); SendClientMessage(playerid,yellow,string); }
			return GivePlayerWeapon(id,id2,strval(tmp3));
	    } else return SendClientMessage(playerid,red,"ERROR: You can not give a disconnected player a weapon.");
	} else return SendLevelErrorMessage(playerid,"giveweapon");
}
But this show me this error
Код:
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "dcmd_giveweapon"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
So i changed it to
Код:
CMD:give weapon(playerid, params[])
and it's show me this Error
Код:
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(116) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(126) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(127) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(315) : warning 219: local variable "id" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(385) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(399) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(409) : warning 219: local variable "id" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(423) : warning 219: local variable "id" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(439) : warning 219: local variable "id" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(472) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(486) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(510) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(524) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(544) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(605) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(619) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(652) : error 001: expected token: "(", but found "-identifier-"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(652) : error 001: expected token: ";", but found "("
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(653) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(654) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(655) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(656) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(657) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(658) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(660) : error 021: symbol already defined: "GetPlayerName"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(661) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(662) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(663) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(664) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(665) : error 010: invalid function or declaration
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "ActionName"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "Index"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "WeaponName"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "id"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "id2"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "name"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "string"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "tmp2"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : warning 203: symbol is never used: "tmp3"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


14 Errors.
how Fix
Reply
#7

i gave you an script try it
Reply
#8

Код:
CMD:giveweapon(playerid, params[])
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveweapon[playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
				return 1;
			}
			new playa;
			new gun;
			new ammo;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			gun = strval(tmp);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /giveweapon [playerid/PartOfName] [weaponid] [ammo]");
				SendClientMessage(playerid, COLOR_GRAD4, "3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
				SendClientMessage(playerid, COLOR_GRAD3, "24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
				return 1;
			}
			if(gun < 1||gun > 46||gun==27||gun==1||gun==2||gun==9||gun==19||gun==20||gun==21||gun==36||gun==39||gun==40||gun==44||gun==45)
			{ SendClientMessage(playerid, COLOR_GRAD1, "   wrong WeaponID!"); return 1; }
			tmp = strtok(cmdtext, idx);
			ammo = strval(tmp);
			if(ammo <1||ammo > 999)
			{ SendClientMessage(playerid, COLOR_GRAD1, "   dont go below 1 or above 999 bullets!"); return 1; }
			if(!IsPlayerAdmin(playerid))			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
						GivePlayerWeapon(playa, gun, ammo);
						GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						format(string, 256, "News: %s has given %s gun id %d.", giveplayer,sendername,gun);
						ABroadCast(COLOR_YELLOW,string,1);

					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
			}
		}
		return 1;
	}
Код:
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(657) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(657) : error 017: undefined symbol "strtok"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(658) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(666) : error 017: undefined symbol "ReturnUser"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(667) : error 017: undefined symbol "strtok"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(668) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(669) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(678) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(678) : error 017: undefined symbol "strtok"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(679) : error 017: undefined symbol "tmp"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(688) : error 017: undefined symbol "giveplayer"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(688) : error 017: undefined symbol "giveplayer"
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(688) : error 029: invalid expression, assumed zero
C:\Users\User\Desktop\GangWar\gamemodes\Test.pwn(688) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


15 Errors.
Reply
#9

This is one of the easiest commands to make, seriously.
pawn Код:
CMD:giveweapon(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) // If they are not RCON admin
    {
        // Then it sends this message
        SendClientMessage(playerid,-1,"You are not authorised to use this command.");
        return 1;
    }
    new
        weaponid,
        targetid,
        ammo;
       
    if(sscanf(params,"uii",targetid,weaponid,ammo))
    {
        // If they typed the command wrong then show them this
        SendClientMessage(playerid,-1,"USAGE: /giveweapon [playerid] [weaponid] [ammo]");
        return 1;
    }
    else
    {
        GivePlayerWeapon(targetid,weaponid,ammo);
        return 1;
    }
    return 1;
}
Reply
#10

Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Thanks working with out any error
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)