Reload all weapons
#1

Hi!


I recently made a "ammo box" System..
To refill your weapons,

But it won't reload/refill all it just takes away some ammo from Desert eagle
and says: Server unknown command.


pawn Код:
Ammobox2[playerid]=1;
SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),100);
SendClientMessage(playerid, Green, "You successfully refilled ammo on your weapons!");
Reply
#2

Well if you want to make a reload thing .. you should make something like

pawn Код:
GetPlayerAmmo(playerid)+ammoyouwanttoadd
And You need to put it in a while loop or a timer to detect if that var is 1 or not
Reply
#3

Dosen't work, I just get compile errors..

And also aren't that function just to see how much ammo a player has?.
Reply
#4

Quote:
Originally Posted by davve95
Посмотреть сообщение
Dosen't work, I just get compile errors..

And also aren't that function just to see how much ammo a player has?.
Would you mind to show us those errors and the lines? You cannot know whether it works or not as long as you get errors and you cannot compile.

Anyways, what -=Dar[K]Lord=- meant was to get the ammo a player has + 100 (that's refilling) because if the player had 200 ammo, it will set them to 100..
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Would you mind to show us those errors and the lines? You cannot know whether it works or not as long as you get errors and you cannot compile.

Anyways, what -=Dar[K]Lord=- meant was to get the ammo a player has + 100 (that's refilling) because if the player had 200 ammo, it will set them to 100..
I didn't give because I thought it were wrong function..
But now I know.

Her's the errors:


pawn Код:
GetPlayerAmmo(playerid,+500);
pawn Код:
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : error 029: invalid expression, assumed zero
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : warning 215: expression has no effect
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : error 001: expected token: ";", but found ")"
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : error 029: invalid expression, assumed zero
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

First one looks more right, but I post this one also, as the example were like that:

pawn Код:
GetPlayerAmmo(playerid) +500);

Код:
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : warning 215: expression has no effect
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : error 001: expected token: ";", but found ")"
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : error 029: invalid expression, assumed zero
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.

If I use just:

GetPlayerAmmo(playerid,500);

pawn Код:
D:\Davids\Scripting\Server Las Venturas TDM mix\LV.pwn(1493) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Just one warning..
Reply
#6

It uses 1 only parameter (playerid).
pawn Код:
GetPlayerAmmo( playerid )
So adding +500 ammo:
pawn Код:
GetPlayerAmmo( playerid ) + 500
Though, you had a mistake. SetPlayerAmmo uses as 2nd parameter weapon slot, not weapon id.
pawn Код:
stock GetWeaponSlot( weaponid )
{
    new
        slot
    ;
    switch( weaponid )
    {
        case 0, 1: slot = 0;
        case 2 .. 9: slot = 1;
        case 10 .. 15: slot = 10;
        case 16 .. 18, 39: slot = 8;
        case 22 .. 24: slot = 2;
        case 25 .. 27: slot = 3;
        case 28, 29, 32: slot = 4;
        case 30, 31: slot = 5;
        case 33, 34: slot = 6;
        case 35 .. 38: slot = 7;
        case 40: slot = 12;
        case 41 .. 43: slot = 9;
        case 44 .. 46: slot = 11;
    }
    return slot;
}
pawn Код:
SetPlayerAmmo( playerid, GetWeaponSlot( GetPlayerWeapon( playerid ) ), GetPlayerAmmo( playerid ) + 500 );
Reply
#7

Something like this?
Quote:

Ammobox2[playerid]=1;
SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),G etPlayerAmmo(playerid)+100);
SendClientMessage(playerid, Green, "You have received 100 rounds of ammo to your current weapon!");

Reply
#8

Quote:
Originally Posted by [LCK]Chris
Посмотреть сообщение
Something like this?
Sounds perfect!, thanks a lot to all!.
Reply
#9

Sorry for bumb!
Long time ago I scripted..

And I noticed the bug...

Anyway:
When I have refilled the weapons it says "Unknown command"

pawn Код:
if (strcmp("/ab", cmdtext, true, 10) == 0)

    {
        SendClientMessage(playerid, Green, "Ammo box!");
        Ammobox2[playerid]=1;
        SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)+500);
        SendClientMessage(playerid, Green, "You successfully refilled ammo on your weapons!");
    }

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/buyammobox", cmdtext, true, 10) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 301.8950,-80.8986,1001.5156))
        if(GetPlayerMoney(playerid) < 2000)
        {
            SendClientMessage(playerid, Red, "You don't have enough money!");
        }
        else
        {
            Ammobox2[playerid]=1;
            GivePlayerMoney(playerid, -2000);
            SendClientMessage(playerid, Green, "You recently bought a ammo box!, use /ab to refill your ammo anywhere!");
        }
        return 1;
    }

Edit: And how can I make so it refills ammo on all weapons??..

And just use it like 4 times, then you don't have it anymore..
Reply
#10

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/ab", cmdtext, true, 10) == 0)
    {
        if (Ammobox2[playerid] && GetPlayerWeapon(playerid))
        {
            SendClientMessage(playerid, Green, "Ammo box!");
            Ammobox2[playerid]=0;
            SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)+500);
            SendClientMessage(playerid, Green, "You successfully refilled ammo on your weapons!");
        }
        return 1;
    }
    if (strcmp("/buyammobox", cmdtext, true, 10) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 301.8950,-80.8986,1001.5156))
        {
            if(GetPlayerMoney(playerid) < 2000)
            {
                SendClientMessage(playerid, Red, "You don't have enough money!");
            }
            else
            {
                Ammobox2[playerid]=1;
                GivePlayerMoney(playerid, -2000);
                SendClientMessage(playerid, Green, "You recently bought a ammo box!, use /ab to refill your ammo anywhere!");
            }
        }
        return 1;
    }
    return 0;
}
You forgot a return at the end of "/ab". Without it, it'll automatically return 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)