Incognito's Streamer question
#1

Why doesn't this delete the pickup?

Global definition:
pawn Код:
new WeaponPID[MAX_DROPPED_WEAPONS];
Creating the pickup:
pawn Код:
CMD:dropwep(playerid, params[])
{
    new
        Float:wepPos[4],
        WeaponID,
        fID = GetOpenWeaponID(),
        WeaponAmmo,
        wepStr[32],
        sendStr[128],
        p_Name[MAX_PLAYER_NAME]
    ;
       
    if(GetPlayerWeapon(playerid) != 0 && GetPlayerAmmo(playerid) != 0) //If they have a weapon..
    {
        GetPlayerPos(playerid, wepPos[0], wepPos[1], wepPos[2]);
        GetPlayerFacingAngle(playerid, wepPos[3]);
        WeaponID = GetPlayerWeapon(playerid);
        WeaponAmmo = GetPlayerAmmo(playerid);
        GetPlayerName(playerid, p_Name, sizeof(p_Name));
       
        format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", fID);
           
        if(!fexist(wepStr))
        {
            new
                INI:wepFile = INI_Open(wepStr);
                   
            INI_SetTag(wepFile, "weapon");
               
            INI_WriteInt(wepFile, "WeaponID", WeaponID);
            INI_WriteInt(wepFile, "WeaponAmmo", WeaponAmmo);
       
            INI_WriteFloat(wepFile, "WeaponX", wepPos[0]);
            INI_WriteFloat(wepFile, "WeaponY", wepPos[1]);
            INI_WriteFloat(wepFile, "WeaponZ", wepPos[2]);
            INI_WriteFloat(wepFile, "WeaponA", wepPos[3]);
               
            INI_WriteInt(wepFile, "WeaponVirtualWorld", GetPlayerVirtualWorld(playerid));
            INI_WriteInt(wepFile, "WeaponInterior", GetPlayerInterior(playerid));
               
            INI_Close(wepFile);
           
            LoadWeapons();
               
            WeaponPID[fID] = CreateDynamicObject(GetWeaponObjectID(droppedWepInfo[fID][gunID]), droppedWepInfo[fID][gunPos][0], droppedWepInfo[fID][gunPos][1], droppedWepInfo[fID][gunPos][2]-1, 80.0, 0.0, 0.0, droppedWepInfo[fID][gunVirtualWorld]);
               
            format(sendStr, sizeof(sendStr), ""#PURPLE"* "#LIME"%s "#PURPLE"has dropped a weapon.", p_Name);
            ProxDetector(20.0, playerid, sendStr, c_PURPLE, c_PURPLE, c_PURPLE, c_PURPLE, c_PURPLE);   
           
            RemovePlayerWeapon(playerid, WeaponID);
           
        }
    }
    return 1;
}
Keystate:
pawn Код:
for( new w; w < MAX_DROPPED_WEAPONS; w++ )
        {
            if(IsPlayerInRangeOfPoint(playerid, 1, droppedWepInfo[w][gunPos][0], droppedWepInfo[w][gunPos][1], droppedWepInfo[w][gunPos][2]))
            {
                if(GetPlayerVirtualWorld(playerid) == droppedWepInfo[w][gunVirtualWorld] && GetPlayerInterior(playerid) == droppedWepInfo[w][gunInterior])
                {
                    new
                        wepStr[32];
                       
                    format(wepStr, sizeof(wepStr), "RPMod/Weapons/%d.ini", w);
                   
                    GivePlayerWeapon(playerid, droppedWepInfo[w][gunID], droppedWepInfo[w][gunAmmo]);
                    DestroyDynamicPickup(WeaponPID[w]);
                   
                    fremove(wepStr);
                   
                    LoadWeapons();
                }
            }
        }
Reply
#2

Try printing the WeaponPID when you set it.

pawn Код:
WeaponPID[fID] = CreateDynamicObject(GetWeaponObjectID(droppedWepInfo[fID][gunID]), droppedWepInfo[fID][gunPos][0], droppedWepInfo[fID][gunPos][1], droppedWepInfo[fID][gunPos][2]-1, 80.0, 0.0, 0.0, droppedWepInfo[fID][gunVirtualWorld]);
printf("Test: %d | %d",fID,WeaponPID[fID]);
Reply
#3

Dropwep:

pawn Код:
printf("Test: %d | %d", fID, WeaponPID[fID]);
Test: 1 | 1

Keystate:
pawn Код:
printf("%d", WeaponPID[w]);
1

The file gets deleted too, which confuses me why the dynamic pickup isn't deleted.
Reply
#4

Which version are you using? 2.6? Do you have the latest revision (r29)?
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Which version are you using? 2.6? Do you have the latest revision (r29)?
I downloaded it straight from the Streamer topic yesterday, so whichever version is on there. Is there a later SVN build available, or?

EDIT: I'm an idiot. Once again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)