SetArmedWeapon
#1

Can anybody help me on how I can set the players weapon to fists and make it so they can only use fists?
Thanks in advance.

PHP код:
if(isAlive[playerid] == false)
        {
            
SetPlayerPos(playeridDeadx[playerid], Deady[playerid], Deadz[playerid]);
            
SetPlayerInterior(playeriddeadint[playerid]);
            
SetPlayerVirtualWorld(playeriddeadvw[playerid]);
            
stopanimAllowed[playerid] = true;
            
SCM(playeridCOLOR_LIGHTRED"You're currently brutally wounded. If no-one helps you, you will die. /acceptdeath if you wish to give up.");
             
TogglePlayerControllable(playerid,1);
             
SetTimerEx("LoadDeathAnim"1000false"i"playerid);
            
SetPlayerSkin(playeridoldskin[playerid]);
            for(new 
0MAX_PLAYERSi++) ShowPlayerNameTagForPlayer(iplayeridtrue);
              new 
string[400];
            new 
holder[400]; 
Reply
#2

To set player's active weapon to fist, use
PHP код:
SetPlayerArmedWeapon(playerid,0); 
To completely remove all weapons and make active one fist, use
PHP код:
ResetPlayerWeapons(playerid); 
Reply
#3

Quote:
Originally Posted by Primes007
Посмотреть сообщение
To set player's active weapon to fist, use
PHP код:
SetPlayerArmedWeapon(playerid,0); 
To completely remove all weapons and make active one fist, use
PHP код:
ResetPlayerWeapons(playerid); 
Thanks, is there a way to lock them into the fists without the player losing their weapons tough?
Reply
#4

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
iCurWeap GetPlayerWeapon(playerid); // Return the player's current weapon        
    
if(iCurWeap != GetPVarInt(playerid"iCurrentWeapon")) // If he changed weapons since the last update
    
{
        
// Lets call a callback named OnPlayerChangeWeapon
        
OnPlayerChangeWeapon(playeridGetPVarInt(playerid"iCurrentWeapon"), iCurWeap);
        
SetPVarInt(playerid"iCurrentWeapon"iCurWeap);//Update the weapon variable
        
SetPlayerArmedWeapon(playerid,0); 
    }
    return 
1// Send this update to other players.
}
 
stock OnPlayerChangeWeapon(playeridoldweaponnewweapon)
{
    new     
s[128],
        
oWeapon[24],
        
nWeapon[24];
 
    
GetWeaponName(oldweaponoWeaponsizeof(oWeapon));
    
GetWeaponName(newweaponnWeaponsizeof(nWeapon));
 
    
format(ssizeof(s), "You changed weapon from %s to %s!"oWeaponnWeapon);
 
    
SendClientMessage(playerid0xFFFFFFFFs);

Code taken from https://sampwiki.blast.hk/wiki/OnPlayerUpdate example and added SetPlayerArmedWeapon(playerid,0);
Reply
#5

Quote:
Originally Posted by Cubie
Посмотреть сообщение
Thanks, is there a way to lock them into the fists without the player losing their weapons tough?
Thank you. +rep
Reply
#6

Another thing you can do is store player weapon data (which should already be done anyway if you have proper anti-cheat) and then reset weapons. This will make it look "smoother" because the player won't be able to cycle through weapons at all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)