Small problem
#1

Okay so this loop doesnt work properly, im trying to get weapon from ground but it doesnt do it

PHP код:
for(new 0sizeof(GunInfo); i++) {
        if(
IsPlayerInRangeOfPoint(playerid,5.0,GunInfo[i][GunX],GunInfo[i][GunY],GunInfo[i][GunZ])) {
            if(
GetPlayerVirtualWorld(playerid) == GunInfo[i][GunWorld]) {
                
DestroyDynamicObject(GunObject[i]);
                
GunInfo[i][GunX] = 2000.00;
                
GunInfo[i][GunY] = 2000.00;
                
GunInfo[i][GunZ] = 3000.00;
                
GunInfo[i][GunWorld] = 666;
                
GivePlayerWeapon(playerid,GunInfo[i][GunWeaponID],GunInfo[i][GunWeaponAmmo]);
                
GunInfo[i][GunX] = 2000.00;
            }
        }
    } 
PHP код:
enum Ddata {
    
GunWeaponID,
    
GunWeaponAmmo,
    
Float:GunX,
    
Float:GunY,
    
Float:GunZ,
    
GunWorld,
    
GunInterior
};
new 
GunInfo[MAX_GUNDROP][Ddata],
    
GunObject[MAX_GUNDROP]; 
Reply
#2

pawn Код:
for(new GunId = 0; GunId < MAX_GUNDROP; GunId++) {
    if( IsPlayerInRangeOfPoint( playerid, 5.0, GunInfo[GunId][GunX], GunInfo[GunId][GunY], GunInfo[GunId][GunZ]) &&
        GetPlayerVirtualWorld(playerid) == GunInfo[GunId][GunWorld])
    {
        GunInfo[GunId][GunX] = 2000.0;
        GunInfo[GunId][GunY] = 2000.0;
        GunInfo[GunId][GunZ] = 3000.0
        GunInfo[GunId][GunWorld] = 666;

        GivePlayerWeapon(playerid, GunInfo[GunId][GunWeaponID], GunInfo[GunId][GunWeaponAmmo]);
                // Consider reseting GunWeaponID and GunWeaponAmmo
                //in here. But maybe it is not necessary.
        break;
    }
}
Reply
#3

Nope still doesnt help

This is how I drop it
PHP код:
DropPlayerGun(playerid,weaponid,ammo,Float:X,Float:Y,Float:Z,World,tmpInt) {
    for(new 
GunId 0GunId MAX_GUNDROPGunId++) {
        if(
GunInfo[GunId][GunX] == 0.0 && GunInfo[GunId][GunY] == 0.0 && GunInfo[GunId][GunZ] == 0.0) {
            
GunInfo[GunId][GunWeaponID] = weaponid;
            
GunInfo[GunId][GunWeaponAmmo] = ammo;
            
GunInfo[GunId][GunX] = X;
            
GunInfo[GunId][GunX] = Y;
            
GunInfo[GunId][GunX] = Z;
            
GunInfo[GunId][GunWorld] = World;
            
GunInfo[GunId][GunInterior] = tmpInt;
            
GunObject[GunId] = CreateDynamicObject(GetGunObjectID(weaponid),X,Y,Z-190.0000, -90.000090.0000WorldtmpInt = -1, -1,200.0);
            return 
true;
        }
    }
    return 
true;

And this is how I pick it up
PHP код:
for(new GunId 0GunId MAX_GUNDROPGunId++) {
        if(
IsPlayerInRangeOfPoint(playerid,5.0,GunInfo[GunId][GunX],GunInfo[GunId][GunY],GunInfo[GunId][GunZ])) {
            if(
GetPlayerVirtualWorld(playerid) == GunInfo[GunId][GunWorld]) {
                
GivePlayerWeapon(playerid,GunInfo[GunId][GunWeaponID],GunInfo[GunId][GunWeaponAmmo]);
                
DestroyDynamicObject(GunObject[GunId]);
                
GunInfo[GunId][GunX] = 2000.00;
                
GunInfo[GunId][GunY] = 2000.00;
                
GunInfo[GunId][GunZ] = 3000.00;
                
GunInfo[GunId][GunWorld] = 666;
                
GunInfo[GunId][GunX] = 2000.00;
            }
        }
    } 
Reply
#4

Please add this line at the end of the loop

Код:
printf("gun picked");
and lemme know if it prints or not, cause I cant see the problem with the loop itself.
Reply
#5

Nope doesnt get to call that one, its like it doesnt get the location correctly.


EDIT: problem fixed, I found a way to do it hehe, I just looped thru the object ID itself. Aka I got dynamic object pos of GunObject and then compared it to my pos
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)