Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on Oct 12, 2015, 02:17 AM

Title: wep function problem
Post by: KAKAN on Oct 12, 2015, 02:17 AM
Here are the functions:-
http://pastebin.com/3NZmYSNV
The problem is I can't use any wep via its ID, I tried validwep function too. Never worked.
Now if I try /wep 32, it tells unknown wep, but if I type /wep m6, it gives me an M6, what's the matter?
Title: Re: wep function problem
Post by: . on Oct 12, 2015, 02:31 AM
Sorry but WHAT DA FUQ ARE YOU TRYING TO DO? For once, just once. Can't you people explain exactly what you're trying to do and do that in a way that it makes sense? Am I supposed to guess what `vargv` is and what's inside ? Dafuq is wrong with you people :-\

I'm going to wait for the next moron who's going to copy your code, make some dumb modifications that he knows nothing about and then give that to you with no explanation and then wait for your reply "not work!". Aren't we tired of that story already?
Title: Re: wep function problem
Post by: KAKAN on Oct 12, 2015, 02:54 AM
Oh, sry!
Here's the wep cmd :P
    else if( cmd == "wep" || cmd == "we")
    {
if (!player.IsSpawned) PrivMessage(player,"You haven't spawned yet.");
else if( !text ) PrivMessage( player, "Syntax error, use /wep <WeaponName>" );
        else GiveWeapons( player, split(text, " ") );
    }

The 'vargv' is the split(text, " ');
Sorry. Can you tell me the problem now :)?
Title: Re: wep function problem
Post by: . on Oct 12, 2015, 03:06 AM
Quote from: KAKAN on Oct 12, 2015, 02:54 AM...
Sorry. Can you tell me the problem now :)?

Nope, because I still don't know what dafuq this code is supposed to do. All I can do is the same thing any noob in here might do. Which is to give you back some shitty code with no idea what its supposed to do.

function ValidWep(wep) // <- DAFUQ is this supposed to do?
{
    switch(wep)
    {
        case 33:
        case 13:
        case 14:
        case 15:
        case 30: return false;
        default: return true;
    }
}         

function GiveWeapons(player, wlist)
{
    local wstring = "", wid = -1;
    foreach (wname in wlist)
     {
        if (IsNum(wname))
        {
            wid = wname.tointeger();
        }
        else
        {
            wid = GetWeaponID(wname);
        }

        if (id == 33)
        {
            wstring += "Unknown";
            //MessagePlayer(">> Error: Some weapons are disabled", player);
        }
        else
        {
            player.SetWeapon(wid, 9999);
            wstring += GetWeaponName(wid);
        }
    }
    MessagePlayer("[#FAF600]>> Giving you: " + wstring + ".", player);
    Announce("~y~Giving you: " + wstring + ".", player, 1);     
}

God I hate stupidity at 6 AM in the morning ::)
Title: Re: wep function problem
Post by: DizzasTeR on Oct 12, 2015, 07:22 AM
else if( cmd == "wep" || cmd == "we" )
{
if( !text ) return MessagePlayer( "[#FF0000]/wep <wep 1> <wep 2> <...>", player );
else
{
local params = split( text, " " ); // Take out the space array
local weapons; // Create a new null variable which will be holding the list of weapons player took.
for( local i = 0; i <= params.len() - 1; i++ ) // since the 'len' returns value from 1 and array's starting value point is 0, we will use len() - 1 otherwise we'll receive an error.
{
if( !IsNum( params[i] ) && GetWeaponID( params[i] ) && GetWeaponID( params[i] ) > 0 && GetWeaponID( params[i] ) <= 32 ) // if Name was specified.
{
player.SetWeapon( GetWeaponID( params[i] ), 99999 ); // Get the weapon ID from its Name
weapons = weapons + " " + GetWeaponName( GetWeaponID( params[i] ) ); // Add the weapon name to given weapon list
}
else if( IsNum( params[i] ) && params[i].tointeger() < 33 && params[i].tointeger() > 0 ) // if ID was specified
{
player.SetWeapon( params[i].tointeger(), 99999 ); // Then just give player that weapon
weapons = weapons + " " + GetWeaponName( params[i].tointeger() ); // Get the weapon name from the ID and add it.
}
else MessagePlayer( "[#FF0000]Invalid Weapon Name/ID!", player ); // if the invalid ID/Name was given
}

if( weapons != null ) MessagePlayer( "[#00FF00]Received weapons: [#FFFFFF]" + weapons );
else MessagePlayer( "[#FF0000]No weapons specified", player );
}
}

Never hesitate to keep your code longer for the sake of efficiency. Don't use a user-defined function everywhere for simple stuff. I tried to keep the explanation simple and understandable.
Title: Re: wep function problem
Post by: KAKAN on Oct 12, 2015, 07:37 AM
Does someone haves a ePrivMessage etc inbuilt?
Title: Re: wep function problem
Post by: MacTavish on Oct 12, 2015, 07:38 AM
Quote from: xxkillerxx on Oct 12, 2015, 07:33 AMtry this hope works
<snip>

Did he asked you for the Snippet. He alreadw made his own and afaik his problem has been already solved by @S.L.C
Title: Re: wep function problem
Post by: KAKAN on Oct 12, 2015, 07:57 AM
Solved my doom killer