SA-MP Forums Archive
Drop gun help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Drop gun help (/showthread.php?tid=591679)



Drop gun help - N0FeaR - 15.10.2015

I made an drop gun system but when i drop the gun is not visible on the ground thanks in advance!

PHP код:
if(strcmp(type, "gun", true) == 0)
        {
            if (
GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
            if(
GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid, COLOR_WHITE, "This is not a valid weapon.");
            if (
PlayerWeapons[playerid][GetPlayerWeapon(playerid)] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The weapon you currently have in your hand is labeld a Hacked Weapon, You are either SA-MP Bugged or Cheating !");
            if(
GetPlayerAmmo(playerid) == 0) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough ammo to drop this weapon.");
            if (
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't be in a vehicle while you use this !");
            
//if(GetPVarInt(playerid, "GunLic") == 1 && ResWeapon(GetPlayerWeapon(playerid))) return SendClientMessage(playerid, COLOR_GREY ,"Ammunation weapons can not be distributed.");
            
new gunname[128], gunid = GetPlayerWeapon(playerid), gunammo = GetPlayerAmmo(playerid);
            
GetWeaponName(GetPlayerWeapon(playerid), gunname, sizeof(gunname));
            
format(string, sizeof(string), "*** %s drops %s %s on the ground.", sendername, CheckSex(playerid),gunname);
            
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
            
GetPlayerPos(playerid,X,Y,Z);
            
RemovePlayerWeaponEx(playerid, GetPlayerWeapon(playerid));
            if(
GetPVarInt(playerid, "Gloves") == 1) sendername="Unknown";
            if(
GetPVarInt(playerid, "Member") != 1 && GetPVarInt(playerid, "Member") != 7)
            {
                new 
amount2 = 0;
                for(new 
i = 0; i < sizeof(DropInfo); i++)
                  {
                      if(
strcmp(PlayerName(playerid), DropInfo[i][dOwner], true) == 0)
                      {
                          
amount2++;
                      }
                  }
                  if(
amount2 <= 1) DropWeapons(gunid,gunammo,X,Y,Z,GetPlayerVirtualWorld(playerid),PlayerName(playerid),sendername); 
stock
PHP код:
stock DropWeapons(gunID,gunAmmo,Float:X,Float:Y,Float:Z,world,owner[],print[])
{
    new 
string[128];
    if(
gunID != 0 && gunAmmo != 0 && ValidDropGunID(gunID))
    {
        for(new 
i = 0; i < sizeof(DropInfo); i++)
          {
              if(
DropInfo[i][dX] == 0.0 && DropInfo[i][dY] == 0.0 && DropInfo[i][dZ] == 0.0)
              {
                  
strmid(DropInfo[i][dOwner], owner, 0, strlen(owner), 255);
                  
strmid(DropInfo[i][dPrint], print, 0, strlen(print), 255);
                  
DropInfo[i][dWeapon] = gunID;
                  
DropInfo[i][dAmmo] = gunAmmo;
                  
DropInfo[i][dX] = X;
                  
DropInfo[i][dY] = Y;
                  
DropInfo[i][dZ] = Z;
                  
DropInfo[i][dWorld] = world;
                  
DropInfo[i][dType] = 1;
                  
DropInfo[i][dObject] = CreateDynamicObject(GetGunObjectID(gunID), X, Y, Z-1, 80.0, 0.0, 0.0, world);
                  
format(string, sizeof(string),"[DEBUG]: Gun Object: %d spawned using Weapon-ID: %d | Ammo-ID: %d | World %d",i,DropInfo[i][dWeapon],DropInfo[i][dAmmo],DropInfo[i][dWorld]);
                  
printf(string);
                return 
1;
              }
        }
    }
    return 
1;
} 



Re: Drop gun help - Morpheine - 15.10.2015

CreatePickup(GetGunObjectID, x, x, etc) it working?


Re: Drop gun help - N0FeaR - 15.10.2015

Quote:
Originally Posted by Morpheine
Посмотреть сообщение
CreatePickup(GetGunObjectID, x, x, etc) it working?
Nah!


Re: Drop gun help - thefirestate - 15.10.2015

I need you to add printf("%f %f %f", X , Y , Z); and tell me it's values.


Re: Drop gun help - N0FeaR - 16.10.2015

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
I need you to add printf("%f %f %f", X , Y , Z); and tell me it's values.
You could explain better!


Re: Drop gun help - Gammix - 16.10.2015

Does this gets printed in your console ?
pawn Код:
format(string, sizeof(string),"[DEBUG]: Gun Object: %d spawned using Weapon-ID: %d | Ammo-ID: %d | World %d",i,DropInfo[i][dWeapon],DropInfo[i][dAmmo],DropInfo[i][dWorld]);
                  printf(string);



Re: Drop gun help - N0FeaR - 16.10.2015

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Does this gets printed in your console ?
pawn Код:
format(string, sizeof(string),"[DEBUG]: Gun Object: %d spawned using Weapon-ID: %d | Ammo-ID: %d | World %d",i,DropInfo[i][dWeapon],DropInfo[i][dAmmo],DropInfo[i][dWorld]);
                  printf(string);
Nah..


Re: Drop gun help - Gammix - 17.10.2015

So this clearly states that these checks
pawn Код:
new string[128];
    if(gunID != 0 && gunAmmo != 0 && ValidDropGunID(gunID))
    {
        for(new i = 0; i < sizeof(DropInfo); i++)
          {
              if(DropInfo[i][dX] == 0.0 && DropInfo[i][dY] == 0.0 && DropInfo[i][dZ] == 0.0)
              {
Are not letting you create a pickup/weapon drop.


Re: Drop gun help - N0FeaR - 25.11.2015

anyone be able to help?


Re: Drop gun help - CmZxC - 25.11.2015

Can you add debug lines to each check to see how far it gets?

PHP код:
    print("1/4");
    if(
gunID != 0 && gunAmmo != 0 && ValidDropGunID(gunID)) 
    {
        print(
"2/4");
        for(new 
i = 0; i < sizeof(DropInfo); i++) 
        {
            print(
"3/4");
            if(
DropInfo[i][dX] == 0.0 && DropInfo[i][dY] == 0.0 && DropInfo[i][dZ] == 0.0) 
            {
                print(
"4/4"); 
and then tell us how far did it get?