How to shorten this up a bit?
#1

pawn Код:
CMD:deagle(playerid, params[])
{
    WeaponReceivedDeagle = 1;
    return 1;
}


CMD:receivedweapon(playerid, params[])
{
    if(WeaponReceivedDeagle == 1)
    {
        GivePlayerWeapon(playerid, 24, 100);
    }
    else if(WeaponReceivedShotgun == 1)
    {
        GivePlayerWeapon(playerid, 25, 100);
    }
    return 1;
}

Is there any way to make it so it's like

new weaponreceived

if(weaponreceived = "deagle");
etc..

and ofc
pawn Код:
CMD:deagle(playerid, params[])
{
    Weaponreceived = "deagle";
    return 1;
}

I'm kinda newb
Reply
#2

give me all the code pawno script i will fix it and back it to u
Reply
#3

There are no bugs or such, I just need to cut it down. Its too big.


I just need to know how to instead of making

pawn Код:
new weaponreceiveddeagle
new weaponreceivedshotgun
new weaponreceivedminigun
I can just make
new weaponreceived = "shotgun" and then if they receive deagle it would actualy be weaponreceived = "deagle" (Set by me).


EX:
pawn Код:
CMD:receivedeagle(playerid, params[])
{
           weaponreceived = "deagle";
           return 1;
}

CMD:receiveshotgun(playerid, params[])
{
           weaponreceived = "shotgun";
           return 1;
}

CMD:what(playerid,params[])
{
            if(weaponreceived = "shotgun")
            {
                       //.................
            }
return 1;
}
Basicaly how to detect it

if I have weapon = "deagle";
how to detect it?

if(weapon == "deagle") bugs...
Reply
#4

pawn Код:
if(strcmp(weaponreceived, "deagle", true) != -1)
Reply
#5

Just save the weapon id

pawn Код:
new WeaponReceived;
//
WeaponReceived = WEAPON_DEAGLE; // or = 24
//
GivePlayerWeapon(playerid, WeaponReceived, 100);
//
new tmp[32];
GetWeaponName(WeaponReceived, tmp, sizeof tmp);
SendClientMessage(playerid, -1, tmp);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)