pickup issue
#1

PHP Code:
public OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == gift1)
    {
        if(
gift1 == 0)
        {
        
gift1=1;
        
SendClientMessage(playerid,0x912334,"got it");
        }
        else if(
gift1 == 1)
        {
        
SendClientMessage(playerid,0x912334,"Lool");
        }
    }
    return 
1;

the first message got it shows but second one lool is not showing after picking up the pickup
Reply
#2

Because your pickid is 0 and you are changing it to 1 so you will never get anymore a message. Plus, an hexadecimal color require Alpha values : 0x912334FF
Reply
#3

That code makes no sense.
if(pickupid==gift1) and again checking the gift1 is 0 or 1....
One thing i can advise you is debug your code using printf and correct the logic in there.
To me the it seems that gift1 var is used a check applicable. But you are using it for both checking the pickup id as well as checking if the pick up of that id is actually picked up.
Reply
#4

PHP Code:
#include <a_samp>
#define FILTERSCRIPT
new gift1;
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
    
gift1 CreatePickup(1905521976.1938,-2380.4646,13.5469, -1);
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
public 
OnPlayerConnect(playerid)
{
    
//gift1 = CreatePickup(19055, 2, 1976.1938,-2380.4646,13.5469, -1);
    
return 1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == gift1)
    {
        if(
gift1 == 0)
        {
        
gift1=1;
        
SendClientMessage(playerid,0x912334,"got it");
        }
        else if(
gift1 == 1)
        {
        
SendClientMessage(playerid,0x912334,"Lool");
        }
    }
    return 
1;

is there any mistakes in these codes
Reply
#5

If you overwrite gift1 (which stores your pickupid) then you will lose the handle to said pickup. The pickup still exists in the world but you can't do anything with it because the handle was lost. If you want to store whether the pickup was picked up by a player then you need a second variable.
Reply
#6

Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
first, you have to move it from static to dynamic. whether you need to use streamer plugin, who can be found on the internet.
Now, let's start:
Code:
    gift1 = CreatePickup(19055, 2, 1976.1938,-2380.4646,13.5469, -1);
Code:
gift1 = CreateDynamicPickup(19055, 2, 1976.1938,-2380.4646,13.5469, -1);
Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
now, what do you want to mean from 'if(gift1 == 0)' ?
make a variable in enum pInfo(or how do you have) with name pGiftTaken for example

Code:
enum pInfo {
pGiftTaken
}
the step two, go on OnPlayerPickUpDynamicPickup:
Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(PlayerInfo[playerid][pGiftTaken] == 0) 
        { 
                PlayerInfo[playerid][pGiftTaken] = 1;
                SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(PlayerInfo[playerid][pGiftTaken] == 1) 
        { 
               SendClientMessage(playerid,0x912334,"Lool");
        } 
    } 
    return 1; 
}
and now you can make this variable saveable(mysql or what you want)
this may fix your problem
Reply
#7

Quote:
Originally Posted by ImTouchk
View Post
Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
first, you have to move it from static to dynamic. whether you need to use streamer plugin, who can be found on the internet.
Now, let's start:
Code:
    gift1 = CreatePickup(19055, 2, 1976.1938,-2380.4646,13.5469, -1);
Code:
gift1 = CreateDynamicPickup(19055, 2, 1976.1938,-2380.4646,13.5469, -1);
Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(gift1 == 0) 
        { 
        gift1=1; 
        SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(gift1 == 1) 
        { 
        SendClientMessage(playerid,0x912334,"Lool"); 
        } 
    } 
    return 1; 
}
now, what do you want to mean from 'if(gift1 == 0)' ?
make a variable in enum pInfo(or how do you have) with name pGiftTaken for example

Code:
enum pInfo {
pGiftTaken
}
the step two, go on OnPlayerPickUpDynamicPickup:
Code:
public OnPlayerPickUpPickup(playerid, pickupid) 
{ 
    if(pickupid == gift1) 
    { 
        if(PlayerInfo[playerid][pGiftTaken] == 0) 
        { 
                PlayerInfo[playerid][pGiftTaken] = 1;
                SendClientMessage(playerid,0x912334,"got it"); 
        } 
        else if(PlayerInfo[playerid][pGiftTaken] == 1) 
        { 
               SendClientMessage(playerid,0x912334,"Lool");
        } 
    } 
    return 1; 
}
and now you can make this variable saveable(mysql or what you want)
this may fix your problem
Did you explain why he can't use normal pickups instead of dynamic? also,Isn't it fine to use any?
Reply
#8

Quote:
Originally Posted by ISmokezU
View Post
Did you explain why he can't use normal pickups instead of dynamic? also,Isn't it fine to use any?
Dynamic is better. Normal pickups had a limit of the pickups(that”s 1000 if i know) but dynamic no. Dynamics are better of running istead anyway.
Reply
#9

No, dynamic pickups are not 'better'. The only time you should use dynamic pickups is when you KNOW that you're going to surpass the limit of 1000 pickups. Otherwise, you should stick purely to CreatePickup.
Reply
#10

Quote:
Originally Posted by ImTouchk
View Post
Dynamic is better. Normal pickups had a limit of the pickups(that”s 1000 if i know) but dynamic no. Dynamics are better of running istead anyway.
Quote:
Originally Posted by Threshold
View Post
No, dynamic pickups are not 'better'. The only time you should use dynamic pickups is when you KNOW that you're going to surpass the limit of 1000 pickups. Otherwise, you should stick purely to CreatePickup.
4096*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)