givegun
#1

PHP код:
CMD:givegun(playeridparams[])
{
    new
        
userid,
        
ammo,
        
weapon;
        
    if (
pInfo[playerid][pAdmin] < 1)
        return 
SendClientMessage(playeridCOLOR_RED"[Server] Nemas dozvolu da koristis ovu komandu.");
    if (
sscanf(params"uii"useridweaponammo))
        return 
SendClientMessage(playerid, -1"Koristenje: /givegun [playerid / deo imena] [weapon id] [ammo]");
    if (
userid == INVALID_PLAYER_ID)
        return 
SendClientMessage(playeridCOLOR_RED,"[Server] Igrac nije konektovan.");
        
    
GivePlayerWeapon(useridweaponammo);
    
    
pInfo[userid][pWeapon] = weapon;
    
pInfo[userid][pAmmo] = ammo;
    
    return 
1;

That is my givegun command, and it works, but what I want here is to make

format like this, so if you can see there is "Deagle" but I don't know how to write it in code, so when I type weaponid 24 (that is Deagle) it shows in format Deagle instead of 24.
[AdmCmd] You have recieved 10 bullets of Deagle from Name_Surname
So if you translate it into code it would be like this

format(string, sizeof(string),"[AdmCmd] You have recieved %d bullets of %s from %s", ammo, DontKnowWhatToTypeHere, PlayerName(playerid);
SCM(.....);

I used ****** but I can't find good explanation for that.
Reply
#2

https://sampwiki.blast.hk/wiki/GetWeaponName
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
I used it already but I guess on wrong way. I don't know how to throw that GetWeaponName into format...I guess you can help me with it?
Reply
#4

Try this out :

PHP код:
CMD:givegun(playeridparams[]) 

    new 
        
userid
        
ammo
        
weapon
        wname
[24]
        new 
string[128]
        
pname[24]; 
    
GetWeaponName(GetPlayerWeapon(playerid),wname,sizeof(wname));
    
GetPlayerName(playerid,pname,24);
         
    if (
pInfo[playerid][pAdmin] < 1
        return 
SendClientMessage(playeridCOLOR_RED"[Server] Nemas dozvolu da koristis ovu komandu."); 
    if (
sscanf(params"uii"useridweaponammo)) 
        return 
SendClientMessage(playerid, -1"Koristenje: /givegun [playerid / deo imena] [weapon id] [ammo]"); 
    if (
userid == INVALID_PLAYER_ID
        return 
SendClientMessage(playeridCOLOR_RED,"[Server] Igrac nije konektovan."); 
    
format(string,sizeof(string),"You have received an %s from %s.",wname,playerid);
    
SendClientMessage(ID,COLOR_YELLOW,string);
         
    
GivePlayerWeapon(useridweaponammo); 
     
    
pInfo[userid][pWeapon] = weapon
    
pInfo[userid][pAmmo] = ammo
     
    return 
1

Reply
#5

It works, thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)