SA-MP Forums Archive
problem in pickups and obj - 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: problem in pickups and obj (/showthread.php?tid=303593)



problem in pickups and obj - barbarking - 14.12.2011

hi.
something has wrong. it doesn't create the pickups and the objs:
pawn Код:
public OnGameModeInit()
{
    SetWeather(2);
    SetGameModeText("RP Mode BETA");
    DisableInteriorEnterExits();
    EnableStuntBonusForAll(0);
    SetTimer("SyncUp", 5000, 1);
    othtimer = SetTimer("OtherTimer", 1000, 1);
    SetTimer("MoneyTimer", 1000, 1);
    for(new playerid = 0; playerid <= MAX_PLAYERS; playerid++) {
    PlayerInfo[playerid][pFirstS] = 0; }
    for(new i=0;i<MAX_VEHICLES;i++)
    engineOn[i]=false;
    for(new i = 0; i <= MAX_PLAYERS; i++)
    AddPlayerClass(98,1217.4446,-1692.5115,19.7344,94.5243,0,0,0,0,0,0);
    noooc = 1;
    first = 0;
    CreatePickup(1318, 23, 1554.9537,-1675.6584,16.1953);
    CreatePickup(1318, 23, 1833.3688,-1842.7252,13.5781);
    return 1;
}



Re: problem in pickups and obj - barbarking - 14.12.2011

btw, i'm using igonito's streamer plugin.


Re: problem in pickups and obj - Psymetrix - 14.12.2011

1) There are no objects created there.

2) CLEAN UP YOUR CODE. There is no need for two of the same loop.

pawn Код:
public OnGameModeInit()
{
    SetGameModeText("RP Mode BETA");
   
    SetWeather(2);
   
    DisableInteriorEnterExits();
    EnableStuntBonusForAll(0);
   
    SetTimer("SyncUp", 5000, 1);
    othtimer = SetTimer("OtherTimer", 1000, 1);
    SetTimer("MoneyTimer", 1000, 1);
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][pFirstS] = 0;
    }
    for(new j = 0; j < MAX_VEHICLES; j++)
    {
        engineOn[j]=false;
    }

    AddPlayerClass(98,1217.4446,-1692.5115,19.7344,94.5243,0,0,0,0,0,0);
   
    noooc = 1;
    first = 0;
   
    CreatePickup(1318, 23, 1554.9537,-1675.6584,16.1953, -1);
    CreatePickup(1318, 23, 1833.3688,-1842.7252,13.5781, -1);
    return 1;
}
3) AddPlayerClass will add a class for every body. You don't add it for every player.

4) for(new i = 0; i <= MAX_PLAYERS; i++) is WRONG!
Remember, when we create a variable like gPlayerVariable[MAX_PLAYERS], we have access to
gPlayerVariable[0] - gPlayerVariable[499] because MAX_PLAYERS is defined as 500.
The proper loop is for(new i = 0; i < MAX_PLAYERS; i++). I would explain more but there is lots of information
available on this subject.

5) As for the pickups. I'm assuming you knew what your doing when you got the co-ordinates.

First of, pickups require a virtual world. https://sampwiki.blast.hk/wiki/CreatePickup
If thats not the problem, try some debugging.

Код:
    new pickupOne = CreatePickup(1318, 23, 1554.9537,-1675.6584,16.1953, -1);
    new pickupTwo = CreatePickup(1318, 23, 1833.3688,-1842.7252,13.5781, -1);
    printf("pickupOne ID: %d, pickupTwo ID: %d", pickupOne, pickupTwo);
Make sure pickupOne and pickupTwo print different values.
It should output something like pickupOne ID: 1, pickupTwo ID: 2

If debugging fails, try different types, models to make sure the ones you are using are valid.

The streamer plugin does not concern this problem.

None of the above code is tested as I'm writing it as i go along, good luck


Re: problem in pickups and obj - TheArcher - 14.12.2011

The native functions for pickups are:

pawn Код:
CreateDynamicPickup(...);
for object is:

pawn Код:
CreateDynamicObject(...);
So change CreatePickup with the aboves one.


Re: problem in pickups and obj - Psymetrix - 14.12.2011

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
The native functions for pickups are:

pawn Код:
CreateDynamicPickup(...);
for object is:

pawn Код:
CreateDynamicObject(...);
So change CreatePickup with the aboves one.
As long as hes under the limit and only uses CreatePickup, he doesn't need to use the streamer.

2 Pickups isn't exactly a reason to use the streamer, is it?


Re: problem in pickups and obj - barbarking - 14.12.2011

Quote:
Originally Posted by Psymetrix
Посмотреть сообщение
1) There are no objects created there.

2) CLEAN UP YOUR CODE. There is no need for two of the same loop.

pawn Код:
public OnGameModeInit()
{
    SetGameModeText("RP Mode BETA");
   
    SetWeather(2);
   
    DisableInteriorEnterExits();
    EnableStuntBonusForAll(0);
   
    SetTimer("SyncUp", 5000, 1);
    othtimer = SetTimer("OtherTimer", 1000, 1);
    SetTimer("MoneyTimer", 1000, 1);
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][pFirstS] = 0;
    }
    for(new j = 0; j < MAX_VEHICLES; j++)
    {
        engineOn[j]=false;
    }

    AddPlayerClass(98,1217.4446,-1692.5115,19.7344,94.5243,0,0,0,0,0,0);
   
    noooc = 1;
    first = 0;
   
    CreatePickup(1318, 23, 1554.9537,-1675.6584,16.1953, -1);
    CreatePickup(1318, 23, 1833.3688,-1842.7252,13.5781, -1);
    return 1;
}
3) AddPlayerClass will add a class for every body. You don't add it for every player.

4) for(new i = 0; i <= MAX_PLAYERS; i++) is WRONG!
Remember, when we create a variable like gPlayerVariable[MAX_PLAYERS], we have access to
gPlayerVariable[0] - gPlayerVariable[499] because MAX_PLAYERS is defined as 500.
The proper loop is for(new i = 0; i < MAX_PLAYERS; i++). I would explain more but there is lots of information
available on this subject.

5) As for the pickups. I'm assuming you knew what your doing when you got the co-ordinates.

First of, pickups require a virtual world. https://sampwiki.blast.hk/wiki/CreatePickup
If thats not the problem, try some debugging.

Код:
    new pickupOne = CreatePickup(1318, 23, 1554.9537,-1675.6584,16.1953, -1);
    new pickupTwo = CreatePickup(1318, 23, 1833.3688,-1842.7252,13.5781, -1);
    printf("pickupOne ID: %d, pickupTwo ID: %d", pickupOne, pickupTwo);
Make sure pickupOne and pickupTwo print different values.
It should output something like pickupOne ID: 1, pickupTwo ID: 2

If debugging fails, try different types, models to make sure the ones you are using are valid.

The streamer plugin does not concern this problem.

None of the above code is tested as I'm writing it as i go along, good luck
i've learned a lot from you, thank you. fixed.