ItsMods

Full Version: improper syntax but i dont know where
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i have attempted to make a mod and its suposed to be a random weapon generator so every time you die you get a random weapon.... but when i launch it i get an improper syntax but im not sure where it is. heres the code if anyone knows let me know because i understand coding to a point and i want to know if i misses something or mesed up typing or its in the wrong spot:

Code:
onPlayerSpawned()
{
     self endon("disconnect");
     self endon("death");
     self Takeallweapons();

     for(;;)
     {
         self waittill("spawned_player");
giveRandomWeapon()
{
     weaponList = [];
     weaponList[weaponList.size] = "ak47_mp";
     weaponList[weaponList.size] = "ak74u_mp";
     weaponList[weaponList.size] = "mp5k_mp";
     weaponList[weaponList.size] = "commando_mp";
     weaponList[weaponList.size] = "l96a1_mp";
     weaponList[weaponList.size] = "dragunov_mp";
     weaponList[weaponList.size] = "wa2000_mp";
     weaponList[weaponList.size] = "m1911dw_mp";
     weaponList[weaponList.size] = "skorpion_mp";
     weaponList[weaponList.size] = "mac11_mp";
     weaponList[weaponList.size] = "uzi_mp";
     weaponList[weaponList.size] = "pm63_mp";
     weaponList[weaponList.size] = "mpl_mp";
     weaponList[weaponList.size] = "spectre_mp";
     weaponList[weaponList.size] = "kiparis_mp";
     weaponList[weaponList.size] = "m16_mp";
     weaponList[weaponList.size] = "enfield_mp";
     weaponList[weaponList.size] = "m14_mp";
     weaponList[weaponList.size] = "famas_mp";
     weaponList[weaponList.size] = "galil_mp";
     weaponList[weaponList.size] = "aug_mp";
     weaponList[weaponList.size] = "fnfal_mp";
     weaponList[weaponList.size] = "g11_mp";
     weaponList[weaponList.size] = "hs10_mp";
     weaponList[weaponList.size] = "rottweil72_mp";
     weaponList[weaponList.size] = "ithaca_mp";
     weaponList[weaponList.size] = "spas_mp";
     weaponList[weaponList.size] = "hk21_mp";
     weaponList[weaponList.size] = "rpk_mp";
     weaponList[weaponList.size] = "m60_mp"
     weaponList[weaponList.size] = "stoner63_mp";
     weaponList[weaponList.size] = "psg1_mp";
     weaponList[weaponList.size] = "aspdw_mp";
     weaponList[weaponList.size] = "cz75dw_mp";
     weaponList[weaponList.size] = "makarovdw_mp";
     weaponList[weaponList.size] = "pythondw_mp";
     weaponList[weaponList.size] = "knife_ballistic_mp";
     weaponList[weaponList.size] = "crossbow_explosive_mp";
     weaponList[weaponList.size] = "minigun_mp";
    


     weapon = weaponList[randomInt( weaponList.size )];
     self giveWeapon( weapon );
     self setSpawnWeapon( weapon );
     self setPerk("specialty_fastreload");
}
}
}

also do i need more files to make it work? (the current file i am having trouble with is _rank.gsc) if i need anything more or anything less or fixed please tell me i am willing to learn.
Code:
onPlayerSpawned()
{
     self endon("disconnect");
     self endon("death");
     for(;;)
     {
        self waittill("spawned_player");
        self takeallweapons();
        wait 0.1;
        self thread GiveRandomWeapon();
    }
}

giveRandomWeapon()
{
     weaponList = [];
     weaponList[weaponList.size] = "ak47_mp";
     weaponList[weaponList.size] = "ak74u_mp";
     weaponList[weaponList.size] = "mp5k_mp";
     weaponList[weaponList.size] = "commando_mp";
     weaponList[weaponList.size] = "l96a1_mp";
     weaponList[weaponList.size] = "dragunov_mp";
     weaponList[weaponList.size] = "wa2000_mp";
     weaponList[weaponList.size] = "m1911dw_mp";
     weaponList[weaponList.size] = "skorpion_mp";
     weaponList[weaponList.size] = "mac11_mp";
     weaponList[weaponList.size] = "uzi_mp";
     weaponList[weaponList.size] = "pm63_mp";
     weaponList[weaponList.size] = "mpl_mp";
     weaponList[weaponList.size] = "spectre_mp";
     weaponList[weaponList.size] = "kiparis_mp";
     weaponList[weaponList.size] = "m16_mp";
     weaponList[weaponList.size] = "enfield_mp";
     weaponList[weaponList.size] = "m14_mp";
     weaponList[weaponList.size] = "famas_mp";
     weaponList[weaponList.size] = "galil_mp";
     weaponList[weaponList.size] = "aug_mp";
     weaponList[weaponList.size] = "fnfal_mp";
     weaponList[weaponList.size] = "g11_mp";
     weaponList[weaponList.size] = "hs10_mp";
     weaponList[weaponList.size] = "rottweil72_mp";
     weaponList[weaponList.size] = "ithaca_mp";
     weaponList[weaponList.size] = "spas_mp";
     weaponList[weaponList.size] = "hk21_mp";
     weaponList[weaponList.size] = "rpk_mp";
     weaponList[weaponList.size] = "m60_mp"
     weaponList[weaponList.size] = "stoner63_mp";
     weaponList[weaponList.size] = "psg1_mp";
     weaponList[weaponList.size] = "aspdw_mp";
     weaponList[weaponList.size] = "cz75dw_mp";
     weaponList[weaponList.size] = "makarovdw_mp";
     weaponList[weaponList.size] = "pythondw_mp";
     weaponList[weaponList.size] = "knife_ballistic_mp";
     weaponList[weaponList.size] = "crossbow_explosive_mp";
     weaponList[weaponList.size] = "minigun_mp";
    


     weapon = weaponList[randomInt( weaponList.size )];
     self giveWeapon( weapon );
     self setSpawnWeapon( weapon );
     self setPerk("specialty_fastreload");
}
You created a function that's not supposed to be there. In GSC you have to "call" the function name.
You create giveRandomWeapon() but you didn't use it properly.


What you can also do is disable some stuff in _class.gsc so you wouldn't need the takeallweapons code or disable killstreaks and such. It's not much of a difference as either one works. If you also need a code to make you automatically select a class do something like...

Code:
onPlayerConnect()
{
    self endon("disconnect");
    for(;;)
    {
        level waittill( "connected", player);
        player thread onPlayerSpawned();
        player thread SetTeam();
    }
}

SetTeam()
{
    self notify("menuresponse", game["menu_team"], "autoassign");
    wait 0.01;
    self notify("menuresponse", "changeclass", "class1");
    wait 0.01;
    return;
}
This will make you automatically spawn when a player connects using the auto-assign functions that's in the game.
(07-28-2013, 00:59)DidUknowiPwn Wrote: [ -> ]
Code:
onPlayerSpawned()
{
     self endon("disconnect");
     self endon("death");
     for(;;)
     {
        self waittill("spawned_player");
        self takeallweapons();
        wait 0.1;
        self thread GiveRandomWeapon();
    }
}

giveRandomWeapon()
{
     weaponList = [];
     weaponList[weaponList.size] = "ak47_mp";
     weaponList[weaponList.size] = "ak74u_mp";
     weaponList[weaponList.size] = "mp5k_mp";
     weaponList[weaponList.size] = "commando_mp";
     weaponList[weaponList.size] = "l96a1_mp";
     weaponList[weaponList.size] = "dragunov_mp";
     weaponList[weaponList.size] = "wa2000_mp";
     weaponList[weaponList.size] = "m1911dw_mp";
     weaponList[weaponList.size] = "skorpion_mp";
     weaponList[weaponList.size] = "mac11_mp";
     weaponList[weaponList.size] = "uzi_mp";
     weaponList[weaponList.size] = "pm63_mp";
     weaponList[weaponList.size] = "mpl_mp";
     weaponList[weaponList.size] = "spectre_mp";
     weaponList[weaponList.size] = "kiparis_mp";
     weaponList[weaponList.size] = "m16_mp";
     weaponList[weaponList.size] = "enfield_mp";
     weaponList[weaponList.size] = "m14_mp";
     weaponList[weaponList.size] = "famas_mp";
     weaponList[weaponList.size] = "galil_mp";
     weaponList[weaponList.size] = "aug_mp";
     weaponList[weaponList.size] = "fnfal_mp";
     weaponList[weaponList.size] = "g11_mp";
     weaponList[weaponList.size] = "hs10_mp";
     weaponList[weaponList.size] = "rottweil72_mp";
     weaponList[weaponList.size] = "ithaca_mp";
     weaponList[weaponList.size] = "spas_mp";
     weaponList[weaponList.size] = "hk21_mp";
     weaponList[weaponList.size] = "rpk_mp";
     weaponList[weaponList.size] = "m60_mp"
     weaponList[weaponList.size] = "stoner63_mp";
     weaponList[weaponList.size] = "psg1_mp";
     weaponList[weaponList.size] = "aspdw_mp";
     weaponList[weaponList.size] = "cz75dw_mp";
     weaponList[weaponList.size] = "makarovdw_mp";
     weaponList[weaponList.size] = "pythondw_mp";
     weaponList[weaponList.size] = "knife_ballistic_mp";
     weaponList[weaponList.size] = "crossbow_explosive_mp";
     weaponList[weaponList.size] = "minigun_mp";
    


     weapon = weaponList[randomInt( weaponList.size )];
     self giveWeapon( weapon );
     self setSpawnWeapon( weapon );
     self setPerk("specialty_fastreload");
}
You created a function that's not supposed to be there. In GSC you have to "call" the function name.
You create giveRandomWeapon() but you didn't use it properly.

ok how do i fix it?
I gave you the proper code for it, just copy and replace it.
(07-28-2013, 01:06)DidUknowiPwn Wrote: [ -> ]I gave you the proper code for it, just copy and replace it.

ok i went to run the mod and go on combat training nuketown and it does the same thing "improper syntax" :/ is there something im missing?
You tell me, run in developer 2 and developer_script 1 (type these in your Black Ops console) and run the match again..
(07-28-2013, 01:24)DidUknowiPwn Wrote: [ -> ]You tell me, run in developer 2 and developer_script 1 (type these in your Black Ops console) and run the match again..

okay thanks but now its says improper syntax at _rank.gsc(47):
weaponList[weaponList.size] = "stoner63_mp";

i know what it means but i spelled it right and im pretty sure its the right dvar or what ever they call it... would there be any way to fix it or just remove that line of code?

(07-28-2013, 19:25)Brandeeno Wrote: [ -> ]
(07-28-2013, 01:24)DidUknowiPwn Wrote: [ -> ]You tell me, run in developer 2 and developer_script 1 (type these in your Black Ops console) and run the match again..

okay thanks but now its says improper syntax at _rank.gsc(47):
weaponList[weaponList.size] = "stoner63_mp";

i know what it means but i spelled it right and im pretty sure its the right dvar or what ever they call it... would there be any way to fix it or just remove that line of code?
k never mind i cant just removed the stoner63 dvar code and its now saying:

improper syntax at _rank.gsc(47):
weaponList[weaponList.size] = "mpl_mp";
im thinking either i have the wrong weapons dvar codes or the line code: weaponList[weaponList.size] = "nameofweapon_mp";
is incorrect or i just to remove the ";" at the end of each : weaponList[weaponList.size] = "nameofweapon";
until i reach the last one

if i remove the line of codes for the weapons each time it will go down the list and eventually all the wepons on the list will be gone ... i have seen this kind of behaviour

is there anything i can do? help please