SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/02/2013, 09:56 PM   #1
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default can set player ammo

So I'm using this code:
pawn Code:
ammo = GetPlayerAmmo(playerid);
amount = 100;
new total = ammo - amount;
SetPlayerAmmo(playerid, GetWeaponSlot(playerid, GetPlayerWeapon(playerid)), total);

And why I can't set ammo for current player selected weapon with this code? Player ammo doesn't changes

GetWeaponSlot:
pawn Code:
stock GetWeaponSlot(playerid,weapon)
{
    new weid,ammo;

    for(new slot=0; slot < 13; slot++)
    {
        new slotas;
        GetPlayerWeaponData(playerid,slotas,weid,ammo);
        if(weid == weapon)
        {
            return slotas;
        }
    }
    return -1;
}
Daslee is offline   Reply With Quote
Old 21/02/2013, 10:04 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: can set player ammo

If in doubt, read the wiki.

http://wiki.sa-mp.com/wiki/SetPlayerAmmo

Weaponid, not slotid.
__________________
Vince is offline   Reply With Quote
Old 22/02/2013, 11:14 AM   #3
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default Re: can set player ammo

Quote:
Originally Posted by Vince View Post
If in doubt, read the wiki.

http://wiki.sa-mp.com/wiki/SetPlayerAmmo

Weaponid, not slotid.
Damn, I am enabled "Function parameters hint on input", and there was weaponslot second parameter as hint, but now I see that it's wrong. Thanks for help!
Daslee is offline   Reply With Quote
Old 22/02/2013, 11:16 AM   #4
sampreader
Little Clucker
 
Join Date: Dec 2011
Posts: 36
Reputation: 35
Default Re: can set player ammo

setplayerammo doesn't work
use giveplayerweapon
sampreader is offline   Reply With Quote
Old 26/02/2013, 10:41 AM   #5
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default Re: can set player ammo

Quote:
Originally Posted by sampreader View Post
setplayerammo doesn't work
use giveplayerweapon
No, it works, at least for me.
Daslee is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reset a variabile when player don't have any ammo Night Dreamer Scripting Help 5 03/12/2012 01:56 PM
How to get player weapon and ammo? ricardo178 Scripting Help 3 25/05/2012 09:02 PM
Hide MiniMap&Player Bullshits(health,ammo,weapon,armour,money) TraNe15 Help Archive 5 19/06/2011 11:40 PM
Player Ammo DRIFT_HUNTER Bug Reports 0 02/01/2011 03:07 PM
Giving player weapon without ammo misko28 Help Archive 3 28/05/2010 06:12 PM


All times are GMT. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.