SA-MP Forums Archive
[Ajuda] Sistema Drop de armas - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Sistema Drop de armas (/showthread.php?tid=626811)



Sistema Drop de armas - LuanGamer - 20.01.2017

Boa noite,
Gostaria de saber se hб como alterar esse cуdigo para que seja bloqueado, que certas armas sejam dropadas, a fim de tornб-las exclusivas, segue o cуdigo:
PHP Code:
CMD:largararma(playerid)
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new 
GunID = GetPlayerWeapon(playerid);
        new 
GunAmmo = GetPlayerAmmo(playerid);
        new 
Float:x, Float:y, Float:z;
        if(
GunID > 0 && GunAmmo != 0)
        {
            new 
f = MAX_OBJ+1;
            for(new 
a = 0; a < MAX_OBJ; a++)
            {
                if(
dGunData[a][ObjPos][0] == 0.0)
                {
                    
f = a;
                    break;
                }
            }
            if(
f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "Vocк nгo pode largar esta arma no momento, tente novamente mais tarde!");
            
RemovePlayerWeapon(playerid, GunID);
            
GetPlayerPos(playerid, x, y, z);
            
CreateDroppedGun(GunID, GunAmmo, x, y, z);
            
ApplyAnimation(playerid,"BOMBER","BOM_Plant_2Idle",4.1,0,1,1,0,0);
            new 
buffer[85];
            
format(buffer, sizeof(buffer), "Vocк largou um(a) %s.", GunNames[dGunData[f][ObjData][0]]);
            
SendClientMessage(playerid, 0x33AA3300, buffer);
            
format(buffer, sizeof(buffer), "* %s colocou um(a) %s no chгo.", NomePlayer(playerid), GunNames[dGunData[f][ObjData][0]]);
            
SendClientMessageInRange(30.0, playerid, buffer, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
printf("%s", buffer);
        }
        return 
1;
    }
    
CMD:parma(playerid)
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new 
f = MAX_OBJ+1;
        for(new 
a = 0; a < MAX_OBJ; a++)
        {
            if(
IsPlayerInRangeOfPoint(playerid, 1.8, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
            {
                
f = a;
                break;
            }
        }
        if(
f > MAX_OBJ) return 1;
        if(
gettime() < GetPVarInt(playerid, #VarFlood8))
            
return 1;
        
SetPVarInt(playerid, #VarFlood8, gettime()+2);
        
GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
        
DestroyDroppedObject(f);
        
ApplyAnimation(playerid,"BOMBER","BOM_Plant_2Idle",4.1,0,1,1,0,0);
        new 
buffer[75];
        
format(buffer, sizeof(buffer), "Vocк pegou um(a) %s.", GunNames[dGunData[f][ObjData][0]]);
          
SendClientMessage(playerid, 0x33AA3300, buffer);
        
format(buffer, sizeof(buffer), "* %s pegou um(a) %s do chгo.", NomePlayer(playerid), GunNames[dGunData[f][ObjData][0]]);
        
SendClientMessageInRange(30.0, playerid, buffer, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        
printf("%s", buffer);
        if(
dGunData[f][ObjData][0] == 47) PlayerInfo[playerid][pExplosivos]++;
          return 
1;
    }
stock CreateDroppedGun(GunID, GunAmmo, Float:gPosX, Float:gPosY, Float:gPosZ)
{
    new 
f = MAX_OBJ+1;
    for(new 
a = 0; a < MAX_OBJ; a++)
    {
        if(
dGunData[a][ObjPos][0] == 0.0)
        {
            
f = a;
            break;
        }
    }
    if(
f > MAX_OBJ) return;
    
dGunData[f][dropTimer] = gettime() + (30*60);//30 minutos para a arma desaparecer
    
dGunData[f][ObjData][0] = GunID;
    
dGunData[f][ObjData][1] = GunAmmo;
    
dGunData[f][ObjPos][0] = gPosX;
    
dGunData[f][ObjPos][1] = gPosY;
    
dGunData[f][ObjPos][2] = gPosZ;
    
dGunData[f][ObjID] = CreateDynamicObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, random(360), -1, -1, -1, 80.0);
    new 
buffer[50];
    
format(buffer, sizeof buffer, "%s",GunNames[dGunData[f][ObjData][0]]);
     
dGunData[f][text3d] = CreateDynamic3DTextLabel(buffer, 0x9ACD32AA, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 80.0);
    return;
}
stock DestroyDroppedObject(dropid)
{
        
DestroyDynamicObject(dGunData[dropid][ObjID]);
        
DestroyDynamic3DTextLabel(dGunData[dropid][text3d]);
        
dGunData[dropid][ObjPos][0] = 0.0;
        
dGunData[dropid][ObjPos][1] = 0.0;
        
dGunData[dropid][ObjPos][2] = 0.0;
        
dGunData[dropid][ObjID] = -1;
        
//dGunData[f][ObjData][0] = 0;
        
dGunData[dropid][ObjData][1] = 0;
        return 
1; 
}


Re: Sistema Drop de armas - FallweN - 20.01.2017

Adicione no comando

pawn Code:
if(GunID == 38) return SendClientMessage(playerid, -1, "Vocк nгo pode largar esta arma"); //ID 38 = Minigun basta colocar a que deseja



Re: Sistema Drop de armas - LuanGamer - 21.01.2017

Muito obrigado! Funcionou realmente. Sу uma ъltima coisa, quando morre as armas as vezes tambйm dropam, estou com dificuldade em achar essa parte quando hб o kill, para bloquear lб tambйm.


Re: Sistema Drop de armas - LuanGamer - 21.01.2017

Acredito que seja nessa parte, mas estou com dificuldade em saber on inserir:

que fica dentro de
Code:
stock OnPlayerDeathEx(playerid, killerid, reason)
PHP Code:
new Float:pPosX, Float:pPosY, Float:pPosZ;
    
GetPlayerPos(playerid, pPosX, pPosY, pPosZ);
for(new 
i_slot = 0, gun, ammo; i_slot != 12; i_slot++)
       {
          
GetPlayerWeaponData(playerid, i_slot, gun, ammo);
           if(
gun != 0 && ammo != 0)
           {
               if(
TempDropArmasBody[playerid] >= 30)
               {
                   
CreateDroppedGun(gun, ammo, pPosX+random(3)-random(3), pPosY+random(3)-random(3), pPosZ);
            }
        }
    }