Blockland Forums > Modification Help
How does this cause a Syntax Error?
Pages: (1/1)
Daenth:
--- Code: --- function GameConnection::spawnPlayer(%client)
{
Parent::spawnPlayer(%client)
--switch(%client.score)--
{
case 2:
%item = akimbopistolItem.getID();
case 3:
%item = akimbopistolItem.getID();
case 4:
%item = machstilItem.getID();
case 5:
%item = machstilItem.getID();
case 6:
%item = magnumItem.getID();
case 7:
%item = magnumItem.getID();
case 8:
%item = pepperpistolItem.getID();
case 9:
%item = pepperpistolItem.getID();
case 10:
%item = combatshotgunItem.getID();
case 11:
%item = combatshotgunItem.getID();
case 12:
%item = huntingshotgunItem.getID();
case 13:
%item = huntingshotgunItem.getID();
case 14:
%item = pumpshotgunItem.getID();
case 15:
%item = pumpshotgunItem.getID();
case 16:
%item = microsmgItem.getID();
case 17:
%item = microsmgItem.getID();
case 18:
%item = submachinegunItem.getID();
case 19:
%item = submachinegunItem.getID();
case 20:
%item = battlerifleItem.getID();
case 21:
%item = battlerifleItem.getID();
case 22:
%item = bullpupItem.getID();
case 23:
%item = bullpupItem.getID();
case 24:
%item = militarysniperItem.getID();
case 25:
%item = militarysniperItem.getID();
case 26:
%item = tcrossbowItem.getID();
case 27:
%item = tcrossbowItem.getID();
case 28:
%item = rpgItem.getID();
case 29:
%item = rpgItem.getID();
case 30:
%item = tierfraggrenadeItem.getID();
case 31:
%item = tierfraggrenadeItem.getID();
}
%player = %client.player;
%slot = 0;
%oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%player,'MsgItemPickup','',%slot,%item);
}
--- End code ---
Comes out with "Syntax Error on line 94!" which has the -- by it.
I don't understand how it comes out to a syntax error. And if there is any way to simplify the case stuff, then please tell me.
rkynick:
I would just stuff the data into an array.
(note it's been a while since I've done this so I might be forgetting something, but you get the general idea)
--- Code: ---function define_item_array(){
$item_array_set=1;
$item_array_start = 2;
$item_array[2] = akimbopistolitem.getID();
$item_array[3] = akimbopistolitem.getID();
$item_array[4] = machstil.getID();
//etc
}
--- End code ---
etc
then
--- Code: ---if(!$item_array_set){
define_item_array();
}
if(%client.score >= $item_array_start){
%item = $item_array[%client.score];
}
--- End code ---
to replace the switch.
However I don't know what your switch issue is, exactly.
Caust:
--- Code: ---Parent::spawnPlayer(%client)
--- End code ---
This needs a semi-colon.
Daenth:
--- Quote from: Caust on June 08, 2011, 09:56:03 PM ---
--- Code: ---Parent::spawnPlayer(%client)
--- End code ---
This needs a semi-colon.
--- End quote ---
Of course I skip over that. =/ Thanks.
--- Quote from: rkynick on June 08, 2011, 09:52:29 PM ---I would just stuff the data into an array.
(note it's been a while since I've done this so I might be forgetting something, but you get the general idea)
--- Code: ---function define_item_array(){
$item_array_set=1;
$item_array_start = 2;
$item_array[2] = akimbopistolitem.getID();
$item_array[3] = akimbopistolitem.getID();
$item_array[4] = machstil.getID();
//etc
}
--- End code ---
etc
then
--- Code: ---if(!$item_array_set){
define_item_array();
}
if(%client.score >= $item_array_start){
%item = $item_array[%client.score];
}
--- End code ---
to replace the switch.
However I don't know what your switch issue is, exactly.
--- End quote ---
I kinda get the jist of it. I'll experiement more with that. Thank you.
Pages: (1/1)