| Blockland Forums > Modification Help |
| Return and Else Scripts |
| << < (2/5) > >> |
| Ipquarx:
Why did you have a random else in the middle of your code with no IF block before it? --- Quote from: elm on June 09, 2012, 10:13:11 PM ---Oh no, not another cityrpg! Lol.. --- End quote --- I know rite? Learning how to script is so horrible. |
| Gordo12699:
function GameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc) { Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc); if (!%client.isAdmin) return; // Message about Stats messageClient('', "<color:ffffff>Your stats have been preserved because you are admin."); %client.RPData.value["tools"] = ""; else;## ## // Lose tools and Clear Stats if (isObject(%client) && %client.isInRP()) return; %client.RPData.value["tools"] = ""; %client.RPData.clear(); } I wanted the bold parts to tie together. Like ifTrue and ifFalse |
| Ipquarx:
You should put a brace after the if, then put in the admin messageclient, then the return, then close the brace. You won't need an else, because it's redundant in this case. |
| Lugnut:
--- Code: ---function GameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc) { Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc); if (%client.isAdmin) { // Message about Stats messageClient('', "<color:ffffff>Your stats have been preserved because you are admin."); %client.RPData.value["tools"] = ""; return; } // Lose tools and Clear Stats if (isObject(%client) && %client.isInRP()) return; %client.RPData.value["tools"] = ""; %client.RPData.clear(); } --- End code --- done |
| Ipquarx:
Turn that last statement into !blah || !stuff and it will be good to go I think. |
| Navigation |
| Message Index |
| Next page |
| Previous page |