GetWeaponPickupCreatePos
#1

Hello, guys I have a problem...
code:
PHP код:
    GetWeaponPickupCreatePos(2467.2654,-1717.5540,13.4988337);
    
GetWeaponPickupCreatePos(2508.7488,-1721.6685,18.5821365);
    
GetWeaponPickupCreatePos(2528.0208,-1678.6014,19.9302372);
    
GetWeaponPickupCreatePos(2539.2712,-1629.6547,13.491622);
    
GetWeaponPickupCreatePos(2545.7944,-1587.3887,13.42871242);
    
GetWeaponPickupCreatePos(2617.0667,-1733.6957,6.2422325); 
Errors:
PHP код:
pickupweapons.pwn(137) : error 035argument type mismatch (argument 1)
pickupweapons.pwn(138) : error 035argument type mismatch (argument 1)
pickupweapons.pwn(139) : error 035argument type mismatch (argument 1)
pickupweapons.pwn(140) : error 035argument type mismatch (argument 1)
pickupweapons.pwn(141) : error 035argument type mismatch (argument 1)
pickupweapons.pwn(142) : error 035argument type mismatch (argument 1
All Code:

https://pastebin.com/r9DzaWkW

I would like to be like this picture... but somehow I can not.
How to do it...?

https://forum.sa-mp.com/attachment.p...1&d=1549910804
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
The Get function gets data. You are passing in constants instead so there’s no way it can return. Consider this:

Код:
GetPlayerPos(playerid, 4.0, 6.0, 8.0);
That can’t work - the last three parameters are to store the position in, but they are just numbers here.
So how do I do that ...? I try it and it is still not possible...

Do I use this code?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Well where did you get it? If you wrote it, why don't you know how it works? If from someone else - ask them.
I removed this symbol '&'. errors disappeared but the weapons did not show up on the servers...

stock GetWeaponPickupCreatePos(&Float, &Float:y, &Float:z, number)
Reply
#4

The & symbol is a reference to a pointer, obviously it won't display the weapons if you remove it.
Reply
#5

Quote:
Originally Posted by Thundey
Посмотреть сообщение
The & symbol is a reference to a pointer, obviously it won't display the weapons if you remove it.
Quote:
Originally Posted by ******
Посмотреть сообщение
Because now you have no data returned at all.

How to do it to make it work?
Reply
#6

Hm...?
Reply
#7

pawn Код:
#include <a_samp>
#include <streamer>

CreateWeaponPickup(weaponid, Float:x, Float:y, Float:z)
{
    weaponid = GetWeaponPickupID(weaponid);
    CreateDynamicPickup(weaponid, 1, x, y, z, -1, -1, -1, STREAMER_PICKUP_SD);
    return 1;
}

GetWeaponPickupID(weaponid)
{
    switch(weaponid)
    {    
        case 1: return 331;
        case 2: return 333;
        case 3: return 334;
        case 4: return 335;
        case 5: return 336;
        case 6: return 337;
        case 7: return 338;
        case 8: return 339;
        case 9: return 341;
        case 10: return 321;
        case 11: return 322;
        case 12: return 323;
        case 13: return 324;
        case 14: return 325;
        case 15: return 326;
        case 16: return 342;
        case 17: return 343;
        case 18: return 344;
        case 22: return 346;
        case 23: return 347;
        case 24: return 348;
        case 25: return 349;
        case 26: return 350;
        case 27: return 351;
        case 28: return 352;
        case 29: return 353;
        case 30: return 355;
        case 31: return 356;
        case 32: return 372;
        case 33: return 357;
        case 34: return 358;
        case 35: return 359;
        case 36: return 360;
        case 37: return 361;
        case 38: return 362;
        case 39: return 363;
        case 40: return 364;
        case 41: return 365;
        case 42: return 366;
        case 43: return 367;
        case 44: return 368;
        case 45: return 369;
        case 46: return 371;
        default: return 1239;
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
pawn Код:
#include <a_samp>
#include <streamer>

CreateWeaponPickup(weaponid, Float:x, Float:y, Float:z)
{
    weaponid = GetWeaponPickupID(weaponid);
    CreateDynamicPickup(weaponid, 1, x, y, z, -1, -1, -1, STREAMER_PICKUP_SD);
    return 1;
}

GetWeaponPickupID(weaponid)
{
    switch(weaponid)
    {    
        case 1: return 331;
        case 2: return 333;
        case 3: return 334;
        case 4: return 335;
        case 5: return 336;
        case 6: return 337;
        case 7: return 338;
        case 8: return 339;
        case 9: return 341;
        case 10: return 321;
        case 11: return 322;
        case 12: return 323;
        case 13: return 324;
        case 14: return 325;
        case 15: return 326;
        case 16: return 342;
        case 17: return 343;
        case 18: return 344;
        case 22: return 346;
        case 23: return 347;
        case 24: return 348;
        case 25: return 349;
        case 26: return 350;
        case 27: return 351;
        case 28: return 352;
        case 29: return 353;
        case 30: return 355;
        case 31: return 356;
        case 32: return 372;
        case 33: return 357;
        case 34: return 358;
        case 35: return 359;
        case 36: return 360;
        case 37: return 361;
        case 38: return 362;
        case 39: return 363;
        case 40: return 364;
        case 41: return 365;
        case 42: return 366;
        case 43: return 367;
        case 44: return 368;
        case 45: return 369;
        case 46: return 371;
        default: return 1239;
    }
    return 1;
}
It's better to use an array to store the IDs instead. Either define a macro that points to the array or access the array content directly.
Reply
#9

Quote:
Originally Posted by ComDuck
Посмотреть сообщение
It's better to use an array to store the IDs instead. Either define a macro that points to the array or access the array content directly.
Why not.

Код:
new WeaponsObject[] = {
    1239,331,333,334,335,336,337,338,
    339,341,321,322,323,324,325,326,
    342,343,344,1239,1239,1239,346,
    347,348,349,350,351,352,353,355,
    356,372,357,358,359,360,361,362,
    363,364,365,366,367,368,369,371
};

#define ReturnWeapon(%0) WeaponsObject[%0]

CreateWeaponPickup(weaponid, Float:x, Float:y, Float:z)
{
    weaponid = ReturnWeapon(weaponid);
    CreateDynamicPickup(weaponid, 1, x, y, z, -1, -1, -1, STREAMER_PICKUP_SD);
    return 1;
}
Notice some invalid weapons ID's values were replaced by 1239.
Reply
#10

My code can not be fixed....? Because when I erase a symbol "&" so error is not, but servers will not show weapons
Reply
#11

Hmmm.... Help me boys
Reply
#12

Quote:
Originally Posted by EmpireSk
Посмотреть сообщение
My code can not be fixed....? Because when I erase a symbol "&" so error is not, but servers will not show weapons
Your code means nothing, the "number" argument is unknown, what is its job? And I wrote you a function up. Use it instead.

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Why not.

Код:
new WeaponsObject[] = {
    1239,331,333,334,335,336,337,338,
    339,341,321,322,323,324,325,326,
    342,343,344,1239,1239,1239,346,
    347,348,349,350,351,352,353,355,
    356,372,357,358,359,360,361,362,
    363,364,365,366,367,368,369,371
};

#define ReturnWeapon(%0) WeaponsObject[%0]

CreateWeaponPickup(weaponid, Float:x, Float:y, Float:z)
{
    weaponid = ReturnWeapon(weaponid);
    CreateDynamicPickup(weaponid, 1, x, y, z, -1, -1, -1, STREAMER_PICKUP_SD);
    return 1;
}
Notice some invalid weapons ID's values were replaced by 1239.
Reply
#13

And will it work ...? is it instead?
Reply
#14

What's even the point of that macro at all? There's no need for it and heck, its bad practice.
Reply
#15

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Notice some invalid weapons ID’s values were replaced by 1239.
Why?
Reply
#16

Quote:
Originally Posted by EmpireSk
Посмотреть сообщение
And will it work ...? is it instead?
Try it...

Quote:
Originally Posted by J0sh...
Посмотреть сообщение
What's even the point of that macro at all? There's no need for it and heck, its bad practice.
Yeah it's just to make it more readable without having to name the variable, it is optional and useless.

Quote:
Originally Posted by ******
Посмотреть сообщение
Why?
Because in his last switch statement it had:

Код:
default: return 1239;
So I replaced all the invalid weapons slots by that, which are between:

Код:
case 18: return 344;
case 22: return 346;
So 19-20-21 were invalid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)