weapon pickup not showing but is there.
#1

Hello samp, Im new here and will probally have some noob questions,
I have been reading this forum for a few days now and have not crossed this problem yet.
Sorry if this has been addressed elsewhere


The armor and health work great just not the shot gun.
the problem is when I place a weapon pickup the item just dont show.
When I go to where it should be it gives me the weapon.
here is my script


pawn Код:
#define FILTERSCRIPT
#include <a_samp>

new PICKUP_ARMOR;
new PICKUP_HEALTH;
new PICKUP_SHOTGUN;

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" PickUps Loaded");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnGameModeInit()
{  
    PICKUP_ARMOR = CreatePickup(1242, 2, 2471.8474,-1712.0262,13.5087, -1);// armor.
    PICKUP_HEALTH = CreatePickup(1240, 2, 2468.9707,-1711.3811,13.5008, -1);// health
    PICKUP_SHOTGUN = CreatePickup(27, 2, 2481.2029,-1703.9849,13.5285, -1);//  SHOTGUN
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == PICKUP_HEALTH)
    {
        return 1;
    }

    if(pickupid == PICKUP_ARMOR)
    {
        return 1;
    }
    if(pickupid == PICKUP_SHOTGUN)
    {
        GameTextForPlayer(playerid, "~w~You Picked up the ShotGun", 5000, 5);
        GivePlayerWeapon(playerid,27,500);
        return 1;
    }
    return 1;
}

thanks
Reply
#2

Your pickup model ID is wrong. As the wiki says (https://sampwiki.blast.hk/wiki/Game_Object_ID_List), shotgun's pickup model ID is 349.
Reply
#3

paste this under OnPlayerSpawn:
pawn Код:
PICKUP_ARMOR = CreatePickup(1242, 2, 2471.8474,-1712.0262,13.5087, -1);// armor.
    PICKUP_HEALTH = CreatePickup(1240, 2, 2468.9707,-1711.3811,13.5008, -1);// health
    PICKUP_SHOTGUN = CreatePickup(349, 2, 2481.2029,-1703.9849,13.5285, -1);//  SHOTGUN
also change your shotgun ID to 349 in your OnGameModeInit as finn said!
Reply
#4

Quote:
Originally Posted by niels44
Посмотреть сообщение
paste this under OnPlayerSpawn:
Don't do that.
Reply
#5

ahh , I dont know why i had that id!

thanks its working now!
Reply
#6

i see how i got the wrong id i was looking at a different page in wiki.

https://sampwiki.blast.hk/wiki/Weapons

what was weird was it gave me the correct gun just wouldn't show.
and using the new ID works.I see they work only when using giveplayerweapon.
Reply
#7

I know you're finished now, but I wanna give you a little tip:

Change this:

PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{   
if(
pickupid == PICKUP_HEALTH)
  {   
       return 
1;
  }  
  
if(
pickupid == PICKUP_ARMOR
   {       
      return 
1
   } 
 
if(
pickupid == PICKUP_SHOTGUN
   {        
      
GameTextForPlayer(playerid"~w~You Picked up the ShotGun"50005);
      
GivePlayerWeapon(playerid,27,500);    
      return 
1;  
   }
   
 return 
1;

To this:

PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{   
if(
pickupid == PICKUP_HEALTH)
  {   
       return 
1;
  }  
  
else if(
pickupid == PICKUP_ARMOR
   {       
      return 
1
   } 
 
else if(
pickupid == PICKUP_SHOTGUN
   {        
      
GameTextForPlayer(playerid"~w~You Picked up the ShotGun"50005);
      
GivePlayerWeapon(playerid,27,500);    
      return 
1;  
   }
   
 return 
1;

Sometimes, it may confuse the server, and also, else-if would be better at this place...
'Cause I heard bad experience about forgetting the else-if and taking instead only if!!
Reply
#8

yeah I see,
I tried a switch case but it said they had to be constants....

ill swap the code now
Im so new to pawn im still learning the querks.

and thanks for the tip!
Reply
#9

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
I know you're finished now, but I wanna give you a little tip:

Change this:

...

Sometimes, it may confuse the server, and also, else-if would be better at this place...
'Cause I heard bad experience about forgetting the else-if and taking instead only if!!
There is absolutely no difference in that case.

I would recommend using switch, a lot easier to read.

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    switch(pickupid)
    {
        case PICKUP_SHOTGUN:
        {
            GameTextForPlayer(playerid, "~w~You Picked up the ShotGun", 5000, 5);
            GivePlayerWeapon(playerid,27,500);    
            return 1;  
        }
        default: return 1;
    }
}
Reply
#10

i tried the switch and the compiler gives error saying
must be a constant.

I wanted to use a switch before i even posted here but ran into this error.

PHP код:
C:\Users\Jon\Desktop\GTASA Server\CC SAMP Server\filterscripts\cc_pickups.pwn(77) : error 008must be a constant expressionassumed zero 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)