Jump to content
Sign in to follow this  
Capital

[PAW] Weapon Dropping

Recommended Posts

Accest sistem poate ajuta pe cineva care vrea un server mai RolePlay si vrea sa fie ca in realitate, atunci cand cineva moare, sa ramana armele juctorului mort pe jos si un alt jucator sa le poate lua. 

```Daca aveti probleme cu implementarea accestui script in GameMode-ul dvs., astept un mesaj in privat si va voi ajuta.```

  • In primul rand adaugam la inceputul GM-ului:
#include <a_samp.inc>
 
#define MAX_DROPPED_WEAPONS          250 // maximul de arme care pot fi pe jos (pe tot server-ul)
 
#define WEAPONS_INFO_TYPE            2   // 0 = Gametext, 1 = 3DText, 2 = Both (atunci cand este langa o arma sau mai multe)
  • Dupa adaugam:
enum wData
{
        wSlotOccupied, // = daca slotul este deja ocupat cu o alta arma.
        wID,
        wAmmo,
        Float:wX,
        Float:wY,
        Float:wZ,
};

new weaponData[MAX_DROPPED_WEAPONS][wData];
new weaponPickup[MAX_DROPPED_WEAPONS];
#if WEAPONS_INFO_TYPE == 1 || WEAPONS_INFO_TYPE == 2
new Text3D:weapon3DText[MAX_DROPPED_WEAPONS];
 
new Float:positionOffsets[13][2] =
{
        {0.75, 0.0},
        {-0.75, 0.0},
        {0.0, 0.75},
        {0.0, -0.75},
        {0.75, 0.75},
        {0.75, -0.75},
        {-0.75, 0.75},
        {-0.75, -0.75},
        {1.50, 0.0},
        {-1.50, 0.0},
        {0.0, 1.50},
        {0.0, -1.50},
        {0.0, 0.0}
};
  • Acum mergem la `OnPlayerKeyStateChange` si adaugam:
       if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
        {
                for(new weaponID = 0; weaponID < sizeof(weaponData); weaponID ++)
                {
                        if(IsPlayerInRangeOfPoint(playerid, 0.5, weaponData[weaponID][wX], weaponData[weaponID][wY], weaponData[weaponID][wZ]))
                        {
                                if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
                                {
                                        if(weaponData[weaponID][wSlotOccupied] == 1)
                                        {
                                                GivePlayerWeapon(playerid, weaponData[weaponID][wID], weaponData[weaponID][wAmmo]);
 
                                                weaponData[weaponID][wSlotOccupied] = 0;
                                                weaponData[weaponID][wID] = 0;
                                                weaponData[weaponID][wAmmo] = 0;
                                                weaponData[weaponID][wX] = 0.0000;
                                                weaponData[weaponID][wY] = 0.0000;
                                                weaponData[weaponID][wZ] = 0.0000;
 
                                                DestroyPickup(weaponPickup[weaponID]);
                                                #if WEAPONS_INFO_TYPE == 1 || WEAPONS_INFO_TYPE == 2
                                                Delete3DTextLabel(weapon3DText[weaponID]);
                                        }
                                }
                        }
                }
        }
  • Dupa Mergem la `OnPlayerPickUpPickup` si adaugam:
        new weaponName[27];
        for(new weaponID = 0; weaponID < sizeof(weaponData); weaponID ++)
        {
                if(pickupid == weaponPickup[weaponID])
                {
                        if(weaponData[weaponID][wSlotOccupied] == 1)
                        {
                                GetWeaponName(weaponData[weaponID][wID], weaponName, sizeof(weaponName));
                                #if WEAPONS_INFO_TYPE == 0 || WEAPONS_INFO_TYPE == 2
                                new stringGameText[256];
                                format(stringGameText, sizeof(stringGameText), "~b~%s ~n~~y~Gloante: ~w~%d ~n~~y~Apasa ~n~~w~~k~~VEHICLE_ENTER_EXIT~                                         ~y~pentru a ridica arma", weaponName, weaponData[weaponID][wAmmo]);
                                GameTextForPlayer(playerid, stringGameText, 3000, 4);
                        }
                }
        }

 

  • Si la sfarsit adaugam:
stock DropPlayerWeapons(playerid)
{
    new Float:playerPos[3], playerVirtualWorld, playerWeapons[13][2], weaponID, string[256];
        GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
    playerVirtualWorld = GetPlayerVirtualWorld(playerid);
 
        for(new playerWeaponSlot = 0; playerWeaponSlot < 12; playerWeaponSlot++) //13 slot = detonater
        {
        weaponID = GetEmptyWeaponIDSlot();
 
            GetPlayerWeaponData(playerid, playerWeaponSlot, playerWeapons[playerWeaponSlot][0], playerWeapons[playerWeaponSlot][1]);
 
            if(playerWeapons[playerWeaponSlot][0] != 0)
            {
                  weaponData[weaponID][wSlotOccupied] = 1;
                  weaponData[weaponID][wID] = playerWeapons[playerWeaponSlot][0];
                  weaponData[weaponID][wAmmo] = playerWeapons[playerWeaponSlot][1];
                  weaponData[weaponID][wX] = playerPos[0] + positionOffsets[playerWeaponSlot][0];
                  weaponData[weaponID][wY] = playerPos[1] + positionOffsets[playerWeaponSlot][1];
                  weaponData[weaponID][wZ] = playerPos[2];
            	  weaponPickup[weaponID] = CreatePickup
                  (
                     GetWeaponModelByID(playerWeapons[playerWeaponSlot][0]), 1,
                     weaponData[weaponID][wX],
                     weaponData[weaponID][wY],
                     weaponData[weaponID][wZ],
                     playerVirtualWorld
                  );
                       
                 #if WEAPONS_INFO_TYPE == 1 || WEAPONS_INFO_TYPE == 2
                 format(string, sizeof(string), "{0049FF}%s \n{F3FF02}Gloante: {FFFFFF}%d \n{F3FF02}Apasa \n{FFFFFF}Enter sau F {F3FF02}pentru a ridica                      arma", weaponName, weaponData[weaponID][wAmmo]);
                 weapon3DText[weaponID] = Create3DTextLabel(string, weaponData[weaponID][wX], weaponData[weaponID][wY], weaponData[weaponID][wZ], 20.0, 0,                    playerVirtualWorld;
                }
        }
        ResetPlayerWeapons(playerid);
        return 1;
}
 
stock GetEmptyWeaponIDSlot()
{
    for(new weaponID = 0; weaponID < sizeof(weaponData); weaponID ++)
        {
                if(weaponData[weaponID][wSlotOccupied] == 0)
                {
                    return weaponID;
                }
        }
        return 0;
}
 
stock GetWeaponModelByID(WeaponID)
{
        if(WeaponID == 1) return 331;
        if(WeaponID == 2) return 333;
        if(WeaponID == 3) return 334;
        if(WeaponID == 4) return 335;
        if(WeaponID == 5) return 336;
        if(WeaponID == 6) return 337;
        if(WeaponID == 7) return 338;
        if(WeaponID == 8) return 339;
        if(WeaponID == 9) return 341;
        if(WeaponID == 10) return 321;
        if(WeaponID == 11) return 322;
        if(WeaponID == 12) return 323;
        if(WeaponID == 13) return 324;
        if(WeaponID == 14) return 325;
        if(WeaponID == 15) return 326;
        if(WeaponID == 16) return 342;
        if(WeaponID == 17) return 343;
        if(WeaponID == 18) return 344;
        if(WeaponID == 22) return 346;
        if(WeaponID == 23) return 347;
        if(WeaponID == 24) return 348;
        if(WeaponID == 25) return 349;
        if(WeaponID == 26) return 350;
        if(WeaponID == 27) return 351;
        if(WeaponID == 28) return 352;
        if(WeaponID == 29) return 353;
        if(WeaponID == 30) return 355;
        if(WeaponID == 31) return 356;
        if(WeaponID == 32) return 372;
        if(WeaponID == 33) return 357;
        if(WeaponID == 34) return 358;
        if(WeaponID == 35) return 359;
        if(WeaponID == 36) return 360;
        if(WeaponID == 37) return 361;
        if(WeaponID == 38) return 362;
        if(WeaponID == 39) return 363;
        if(WeaponID == 41) return 365;
        if(WeaponID == 42) return 366;
        if(WeaponID == 43) return 367;
        if(WeaponID == 46) return 371;
        else return -1;
}

 

Share this post


Link to post
Share on other sites

Pare super ok sistemul tau... dar se poate face foarte mult abuz dupa parerea mea.. de exemplu: un hitman moare cu sniper si un civil il ia :) intelegi? Felicitari pentru munca depusa oricum.

Share this post


Link to post
Share on other sites
Just now, AT RatoN said:

Pare super ok sistemul tau... dar se poate face foarte mult abuz dupa parerea mea.. de exemplu: un hitman moare cu sniper si un civil il ia :) intelegi? Felicitari pentru munca depusa oricum.

Da se pot face doar la armele gen Knife, Baseball, etc.. armele albe.

Share this post


Link to post
Share on other sites

Topic Closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.