/Dropgun doesn't create the object
#1

Heya, I started editing a Dropgun script :
http://forum.sa-mp.com/showthread.ph...ht=drop+weapon

I tried putting it into my mode but when you /dropgun, it doesn't create the object
And when you /pickupgun, it doesn't say the weapon's name
I'm pretty sure it's just not receiving the gun name from the array

/Dropgun
PHP код:
CMD:dropgun(playeridparams[])
{
    if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
     new 
GunID GetPlayerWeapon(playerid);
      new 
GunAmmo GetPlayerAmmo(playerid);
    if(
GunID && GunAmmo != 0)
    {
        new 
MAX_OBJ+1;
         for(new 
0MAX_OBJa++)
          {
               if(
dGunData[a][ObjPos][0] == 0.0)
            {
            
a;
            break;
            }
        }
    if(
MAX_OBJ) return SendClientMessage(playerid0x33AA3300"You can not throw weapons at the moment, try back later!");
    
RemovePlayerWeapon(playeridGunID);
    
dGunData[f][ObjData][0] = GunID;
    
dGunData[f][ObjData][1] = GunAmmo;
    
GetPlayerPos(playeriddGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
    
dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-193.7120.0120.0);
    new 
buffer[50];
    
format(buffersizeof(buffer), "You threw %s"GunNames[dGunData[f][ObjData][0]]);
    
SendClientMessage(playerid0x33AA3300buffer);
    }
       return 
1;

/Pickupgun
PHP код:
CMD:pickupgun(playeridparams[])
{
    if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
    new 
MAX_OBJ+1;
    for(new 
0MAX_OBJa++)
    {
        if(
IsPlayerInRangeOfPoint(playerid5.0dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
        {
            
a;
            break;
        }
    }
    if(
MAX_OBJ) return SendClientMessage(playerid0x33AA3300"You are not near the weapon which you can pick up!");
    
DestroyObject(dGunData[f][ObjID]);
    
GiveDodWeapon(playeriddGunData[f][ObjData][0], dGunData[f][ObjData][1]);
    
dGunData[f][ObjPos][0] = 0.0;
    
dGunData[f][ObjPos][1] = 0.0;
    
dGunData[f][ObjPos][2] = 0.0;
    
dGunData[f][ObjID] = -1;
    
dGunData[f][ObjData][0] = 0;
    
dGunData[f][ObjData][1] = 0;
    new 
buffer[50];
    
format(buffersizeof(buffer), "You picked up %s"GunNames[dGunData[f][ObjData][0]]);
      
SendClientMessage(playerid0x33AA3300buffer);
    return 
1;

GunNames array
PHP код:
new GunNames[48][] = {
    
"Nothink""Brass Knuckles""Golf Club""Nitestick""Knife""Baseball Bat",
    
"Showel""Pool Cue""Katana""Chainsaw""Purple Dildo""Small White Dildo",
    
"Long White Dildo""Vibrator""Flowers""Cane""Grenade""Tear Gas""Molotov",
    
"Vehicle Missile""Hydra Flare""Jetpack""Glock""Silenced Colt""Desert Eagle",
    
"Shotgun""Sawn Off""Combat Shotgun""Micro UZI""MP5""AK47""M4""Tec9",
    
"Rifle""Sniper Rifle""Rocket Launcher""HS Rocket Launcher""Flamethrower""Minigun",
    
"Satchel Charge""Detonator""Spraycan""Fire Extinguisher""Camera""Nightvision",
    
"Infrared Vision""Parachute""Fake Pistol"
}; 
GunObjcets array
PHP код:
new GunObjects[47] = {
    
0,331,333,334,335,336,337,338,339,341,321,322,323,324,325,326,342,343,344,
    
0,0,0,346,347,348,349,350,351,352,353,355,356,372,357,358,359,360,361,362,
    
363,364,365,366,367,368,368,371
}; 
Reply
#2

bump
Reply
#3

In pickupgun you are resetting dGunData[f][ObjData][0] so GunNames should show "Nothink"
Reply
#4

Quote:
Originally Posted by Jefff
Посмотреть сообщение
In pickupgun you are resetting dGunData[f][ObjData][0] so GunNames should show "Nothink"
Stupid me
It was with "//" at the start so I thought I had to untag it
Reply
#5

and here is updated version without unnecessary arrays in enum

pawn Код:
#define MAX_OBJ 50 // Limit
// -----------------------------------------------------------------------------
enum dGunEnum
{
    ObjData[3]
};
new dGunData[MAX_OBJ][dGunEnum];

CMD:dropgun(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
    new GunID = GetPlayerWeapon(playerid);
    new GunAmmo = GetPlayerAmmo(playerid);
    if(GunID > 0 && GunAmmo > 0)
    {
        new slot = -1;
        for(new i = 0; i < MAX_OBJ; i++)
            if(dGunData[i][ObjData][0] == 0)
            {
                slot = i;
                break;
            }

        if(slot < 0) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
        RemovePlayerWeapon(playerid, GunID);
        dGunData[slot][ObjData][1] = GunID;
        dGunData[slot][ObjData][2] = GunAmmo;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        dGunData[slot][ObjData][0] = CreateObject(GunObjects[GunID], x, y, z-1.0, 93.7, 120.0, 120.0);
        new buffer[50];
        format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[slot][ObjData][1]]);
        SendClientMessage(playerid, 0x33AA3300, buffer);
    }
    return 1;
}

CMD:pickupgun(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;

    new slot = -1;
    new Float:x, Float:y, Float:z;
    for(new i = 0; i < MAX_OBJ; i++)
        if(dGunData[i][ObjData][0] > 0 && IsValidObject(dGunData[i][ObjData][0]))
        {
            GetObjectPos(dGunData[i][ObjData][0], x, y, z);
            if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
            {
                slot = i;
                break;
            }
        }

    if(slot < 0) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
    DestroyObject(dGunData[slot][ObjData][0]);
    GiveDodWeapon(playerid, dGunData[slot][ObjData][1], dGunData[slot][ObjData][2]);
    dGunData[slot][ObjData][0] = 0;
    new buffer[50];
    format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[slot][ObjData][1]]);
    SendClientMessage(playerid, 0x33AA3300, buffer);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)