| Blockland Forums > Modification Help |
| Problem with Achievements Server.cs Edition |
| (1/3) > >> |
| Paper Mario Fan:
When I downloaded the achievements mod in RTB, I decided to add my own achievements to it with the help of the tutorial in the add-on's description. But when I spawned in my server, it wasn't working. This is the full code. --- Code: ---$Achievements::Version = 10; // Load the triggers after everything else. schedule(4000, 0, exec, "Add-ons/Script_achievements/triggers.cs"); if(!isFunction("isInt")) exec("./compat.cs"); function LoadBaseTriggers() { exec("./base_triggers.cs"); } function sendLockedAchievementToClient(%client, %bitmapImage, %name, %text) { %name = StripMLControlChars(%name); %text = StripMLControlChars(%text); if(%name $= "") return echo("Missing Var! (sendAchievementToClient)"); if(!%client.hasAchievementsMod) return; commandtoclient(%client, 'AddAch', %bitmapImage, %name, %text); %client.Achievements[%name] = true; } function unlockClientAchievement(%client, %name) { %name = StripMLControlChars(%name); if(%name $= "") return echo("Missing Var! (unlockClientAchievement)"); if(%client.unLockedAchievements[%name] || !%client.hasAchievementsMod) return; commandtoclient(%client, 'UnlockAch', %name); messageAll('MsgAdminForce', '\c3%1 \c6completed the <color:CC0000>%2 \c6Achievement!', %client.name, %name); PlayAchievementAlert(); %client.unLockedAchievements[%name] = true; %file = new FileObject(); %file.openForAppend("config/Achievements/saves/"@%client.BL_ID@".txt"); %file.writeLine(%name); %file.close(); %file.delete(); } function loadClientAchievements(%client) { if(!%client.hasAchievementsMod) return; %file = new FileObject(); %file.openForRead("config/Achievements/saves/"@%client.BL_ID@".txt"); while(!%file.isEOF()) { %line = %file.readLine(); if(%line !$= "") { %data['Name'] = getField(%line, 0); %client.unLockedAchievements[%data['Name']] = true; commandtoclient(%client, 'UnlockAch', %data['Name']); } } %file.close(); %file.delete(); } function clearClientAchievements(%client) { if(!%client.hasAchievementsMod) return; commandtoclient(%client, 'clearAch'); } package AchClientEnterGame { function GameConnection::AutoAdminCheck(%client) { commandtoClient(%client, 'IHaveAchievementsMod'); return Parent::AutoAdminCheck(%client); } function gameConnection::onClientEnterGame(%this) { parent::onClientEnterGame(%this); messageClient(%this, '', "\c3Server is running DarkLight's Achievements Mod Version" SPC $Achievements::Version @ "."); clearClientAchievements(%this); sendAchievements(%this); loadClientAchievements(%this); if(%this.isAdmin) { unlockClientAchievement(%this, "Power of God"); } if(%this.BL_ID $= 3706) $Achievements::Maker::inServer = true; if($Achievements::Maker::inServer == true) { for(%i=0; %i < ClientGroup.getCount(); %i++) { %c = ClientGroup.getObject(%i); if(isObject(%c.player)) { unlockClientAchievement(%c, "Meet The Maker"); } } } if(%this.BL_ID $= 0) $Achievements::Badspot::inServer = true; if($Achievements::Badspot::inServer == true) { for(%i=0; %i < ClientGroup.getCount(); %i++) { %c = ClientGroup.getObject(%i); if(isObject(%c.player)) { unlockClientAchievement(%c, "Badspot?!?"); } } } if(%this.BL_ID $= <censored>) //This is censored to hide the mystery BL_ID. The actual code does not censor this. $Achievements::Mystery::inServer = true; if($Achievements::Mystery::inServer == true) { for(%i=0; %i < ClientGroup.getCount(); %i++) { %c = ClientGroup.getObject(%i); if(isObject(%c.player)) { unlockClientAchievement(%c, "Mystery Person...?"); } } } if(getSubStr(getdatetime(), 0, 5) $= "12/25") { unlockClientAchievement(%this, "Christmas Day"); } } function gameConnection::OnClientLeaveGame(%this) { if(%this.BL_ID $= 3706) $Achievements::Maker::inServer = false; Parent::OnClientLeaveGame(%this); } }; package AchStuff { function sendAchievements(%client) { sendLockedAchievementToClient(%client, "pwned", "My First Kill", "Make your first kill."); sendLockedAchievementToClient(%client, "target", "Devils Shotgun", "Kill 666 players."); sendLockedAchievementToClient(%client, "hugger", "Hugs Make Things Better", "Type /hug."); sendLockedAchievementToClient(%client, "mw", "Meet The Maker", "Meet DarkLight in any server that has this addon"); sendLockedAchievementToClient(%client, "censored", "I Think it Burns", "Jump in to a pool of lava."); sendLockedAchievementToClient(%client, "weirdface", "Power of God", "Become an admin. This one is too easy!"); sendLockedAchievementToClient(%client, "pacman", "My First 100", "Plant your first 100 bricks."); sendLockedAchievementToClient(%client, "blablabla", "Ooooo, what does THIS button do?", "Legitly ban a player."); sendLockedAchievementToClient(%client, "middlefinger", "Cut The Light", "Kill DarkLight in a game of Deathmatch (Which he hates)."); sendLockedAchievementToClient(%client, "...", "Badspot?!?", "The one and only!"); sendLockedAchievementToClient(%client, "lol", "TURN OFF THAT HORRIBLE MUSIC!!!", "Meet TheToxicRadio, TECK's archenemy, and pwn him in a deathmatch."); sendLockedAchievementToClient(%client, "unknown", "Mystery Person...?", "Meet a person who only TECK knows, 'cause he made this achievement!"); sendLockedAchievementToClient(%client, "crap", "BO-SCHITT!!!", "Piss TECK off by killing him in a deathmatch 5 times in a row."); sendLockedAchievementToClient(%client, "wierdface", "How lucky you are!", "Build 77777 bricks."); sendLockedAchievementToClient(%client, "eye", "The Secret Spot", "Find the secret spot."); sendLockedAchievementToClient(%client, "fail", "Fallure", "Fall ten times and die."); sendLockedAchievementToClient(%client, "pa", "Madness", "Meet Tezuni, the one with tons of drama topics."); sendLockedAchievementToClient(%client, "mouse", "Christmas Day", "Play in a Blockland server on Christmas day!"); } function startGame() { parent::startGame(); schedule(1000, 0, LoadBaseTriggers); } function GameConnection::onDeath(%this, %killerPlayer, %killer, %damageType, %damageLoc) { %client = %this.player.client; if(%killer.name !$= %client.name && %killer.name !$= "") { unlockClientAchievement(%killer, "My First Kill"); } if(%killer.name !$= %client.name && %client.BL_ID $= 3706 && %killer.name !$= "") { unlockClientAchievement(%killer, "Cut The Light"); } if(%killer.name !$= %client.name && %client.BL_ID $= 21575 && %killer.name !$= "" && %client.BL_ID.deathCount == 5) { unlockClientAchievement(%killer, "BO-SCHITT!!!"); } if(%killer.name !$= %client.name && %client.BL_ID $= 11076 && %killer.name !$= "") { unlockClientAchievement(%killer, "TURN OFF THAT HORRIBLE MUSIC!!!"); } if(!%killer.unLockedAchievements["Devils Shotgun"]) { %killer.killCount++; if(%killer.killCount == 666) { unlockClientAchievement(%killer, "Devils Shotgun"); } } if(!%client.unLockedAchievements["Fallure"] && %damageType $= $DamageType::Fall) { %client.deathCount++; if(%client.deathCount == 10) { unlockClientAchievement(%client, "Fallure"); } } parent::onDeath(%this, %killerPlayer, %killer, %damageType, %damageLoc); } function serverCmdSad(%client, %password) { parent::serverCmdSad(%client, %password); if(%password $= $Pref::Server::AdminPAssword || %password $= $Pref::Server::SuperAdminPassword) { unlockClientAchievement(%client, "Power of God"); } } function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType) { if(%damageType $= "0.01") { unlockClientAchievement(%obj.client, "I Think it Burns"); } parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType); } function serverCmdPlantBrick(%client) { parent::serverCmdPlantBrick(%client); if(%client.brickgroup.getcount() >= 100) { unlockClientAchievement(%client, "My First 100"); } } if(%client.brickgroup.getcount() >= 77777) { unlockClientAchievement(%client, "How lucky you are!"); } function serverCmdBan(%client, %name, %id, %time, %reason) { parent::serverCmdBan(%client, %name, %id, %time, %reason); // I don't know why I even added this. if(%client.isAdmin && %client != %name && !%name.isSuperAdmin) { unlockClientAchievement(%client, "Ooooo, what does THIS button do?"); } } function serverCmdHug(%client) { if(isObject(%client.player)) unlockClientAchievement(%client, "Hugs Make Things Better"); parent::serverCmdHug(%client); } }; function serverCmdIHaveAchievementsMod(%client) { %client.hasAchievementsMod = true; } function PlayAchievementAlert() { for(%i=0; %i < ClientGroup.getCount(); %i++) { %cl = ClientGroup.getObject(%i); %cl.play2D(AchievementUnlockedSound); } } activatepackage(AchClientEnterGame); activatepackage(AchStuff); exec("./AchPack_1/map_related.cs"); exec("./AchPack_1/admin_related.cs"); datablock AudioProfile(AchievementUnlockedSound) { filename = "./completed.wav"; description = AudioClose3d; is3D = true; preload = true; }; --- End code --- Yes...I know. In a MILLION YEARS Badspot and/or a random BL_ID would join my server. I decided I would add one of these for lulz. On topic: PLEASE HELP!!! |
| Paper Mario Fan:
Bump. |
| Red_Guy:
need a few more details other than "not working" console errors? weird messages? pc explodes? crash? .... what? |
| Paper Mario Fan:
--- Quote from: Paper Mario Fan on March 20, 2011, 12:26:17 PM --- --- Code: --- if(%this.BL_ID $= 0) $Achievements::Badspot::inServer = true; if($Achievements::Badspot::inServer == true) { for(%i=0; %i < ClientGroup.getCount(); %i++) { %c = ClientGroup.getObject(%i); if(isObject(%c.player)) { unlockClientAchievement(%c, "Badspot?!?"); } } } if(%this.BL_ID $= <censored>) //This is censored to hide the mystery BL_ID. The actual code does not censor this. $Achievements::Mystery::inServer = true; if($Achievements::Mystery::inServer == true) { for(%i=0; %i < ClientGroup.getCount(); %i++) { %c = ClientGroup.getObject(%i); if(isObject(%c.player)) { unlockClientAchievement(%c, "Mystery Person...?"); } } } sendLockedAchievementToClient(%client, "...", "Badspot?!?", "The one and only!"); sendLockedAchievementToClient(%client, "lol", "TURN OFF THAT HORRIBLE MUSIC!!!", "Meet TheToxicRadio, TECK's archenemy, and pwn him in a deathmatch."); sendLockedAchievementToClient(%client, "unknown", "Mystery Person...?", "Meet a person who only TECK knows, 'cause he made this achievement!"); sendLockedAchievementToClient(%client, "crap", "BO-SCHITT!!!", "Piss TECK off by killing him in a deathmatch 5 times in a row."); sendLockedAchievementToClient(%client, "wierdface", "How lucky you are!", "Build 77777 bricks."); if(%killer.name !$= %client.name && %client.BL_ID $= 21575 && %killer.name !$= "" && %client.BL_ID.deathCount == 5) { unlockClientAchievement(%killer, "BO-SCHITT!!!"); } if(%killer.name !$= %client.name && %client.BL_ID $= 11076 && %killer.name !$= "") { unlockClientAchievement(%killer, "TURN OFF THAT HORRIBLE MUSIC!!!"); } if(%client.brickgroup.getcount() >= 77777) { unlockClientAchievement(%client, "How lucky you are!"); } --- End code --- --- End quote --- These are the editions I made to the script. EDIT: By "not working", I mean the keybind for the GUI did not appear in the comtrols tab. And I barely even touched the Keybind code. |
| Paper Mario Fan:
Bring Up My Posts. |
| Navigation |
| Message Index |
| Next page |