How can I do this?
#1

Hello everybody,

I want to do when you have a desert eagle, for example, you can't change this weapon with the mouse scroll or "q/e". This weapon have to stay always in your hand. Can enyone help me?
Reply
#2

Code:
public OnPlayerUpdate(playerid)
{
    new weapons[14][2];
    for(new i=0; i<13; i++)
   {
       	GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
        if(weapons[i][0] == 24)
        {
            SetPlayerArmedWeapon(playerid, 24);
        }
    }
    return 1;
}
You can also use this code under a timer, OnPlayerUpdate is called more than 50 times in a second.
Reply
#3

By Using this SetPlayerArmedWeapon(playerid,**);

PHP Code:

public OnPlayerStateChange(playeridnewstateoldstate)
    
    {
        new 
gun GetPlayerWeapon(playerid);
        if((
27 gun 33)) SetPlayerArmedWeapon(playeridgun);
        else
        {
         
SetPlayerArmedWeapon(playerid0); // any you want to use
    
}
    return 
1;

PHP Code:
OnPlayerChangeWeapon(playeridnewweapon)
SetPlayerArmedWeapon(playerid,23); 
I just give you hint . Now make it properly for your own server

Also Follow

Quote:
Originally Posted by Tamy
View Post
Code:
public OnPlayerUpdate(playerid)
{
    new weapons[14][2];
    for(new i=0; i<13; i++)
   {
       	GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
        if(weapons[i][0] == 24)
        {
            SetPlayerArmedWeapon(playerid, 24);
        }
    }
    return 1;
}
You can also use this code under a timer, OnPlayerUpdate is called more than 50 times in a second.
Reply
#4

You could give a try to this:

PHP Code:
new LockWeapon[MAX_PLAYERS];
new 
LockOn[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
LockOn[playerid] = 0;
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    if(
LockOn[playerid] == 1)
    {
        if(
GetPlayerWeapon(playerid) != LockWeapon[playerid]) SetPlayerArmedWeapon(playeridLockWeapon[playerid]);
    }
    return 
1;
}
stock LockPlayerWeapon(playeridweaponid)
{
    
LockOn[playerid] = 1;
    
LockWeapon[playerid] = weaponid;
    return 
1;
}
stock UnlockPlayerWeapon(playerid)
{
    
LockOn[playerid] = 0;
    
LockWeapon[playerid] = -1;

Use LockPlayerWeapon(playerid, weaponid) to lock the weapon.
Use UnlockPlayerWeapon(playerid) unlock the weapon.
Reply
#5

@Michael - Use booleans and a timer instead. You do not always need that code to run, I assume.
Reply
#6

Thank you @Tamy and @SoFahim.

Solved
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)