Author Topic: What is wrong with my script?  (Read 1419 times)

Thanks to Truce, I got this to work. LOCK
« Last Edit: April 10, 2009, 09:47:37 PM by massa900 »

What is wrong with my script? Here it is:
Code: [Select]
//Right here is where it it suppose to let you join my server membership

function serverCmdBecomeMember(%client)
{
%client.hasServerMembership = 1;
messageAll("," @ %client.name SPC " is now a server member");
messageBoxOK("FliFiX Server","\c2Thank you for joining FliFiX's Server Membership, %1. You are now known as a member.");
}

//Then, right here, it will update your membership / admin status. Lets say you just became a member, then, you would type /updatemembership and then your name when you chat would be: [Member] : NAMEHERE : CHATMSGHERE

function serverCmdUpdateMembership(%client)
{
{
if(%client.hasServerMembership)
{
if(%client.isSuperAdmin == false || %client.isAdmin == false || %client.isHost == false)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Member] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
else
{
if(%client.isSuperAdmin == false || %client.isAdmin == false || %client.isHost == false)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Guest] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
}
{
if(%client.isAdmin == true || %client.isSuperAdmin == false || %client.isHost == false)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Admin] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
{
if(%client.isAdmin == false || %client.isSuperAdmin == true || %client.isHost == false)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Super Admin] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
{
if(%client.isAdmin == false || %client.isSuperAdmin == false || %client.isHost == true)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Host] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
}
First of all you are using " in messagealls instead of two 's. You only need the two 's in the beginning, like messageAll(' ',"Message");
Second, clanPrefixes and clanSuffixes can not be altered in v11, Badspot restricted it due to people puting code to make their name big in their clanprefix.

What exactly is the error you're encountering? Not working? Syntax error? Specific instance?

Second, clanPrefixes and clanSuffixes can not be altered in v11, Badspot restricted it due to people puting code to make their name big in their clanprefix.
I've done it in my server to distinguish me from my brother in chat when he's in the server. Works fine.

Code: [Select]
function serverCmdBecomeMember(%client)
{
%client.hasServerMembership = 1;
messageAll(''," @ %client.name SPC " is now a server member");
messageBoxOK("FliFiX Server","\c2Thank you for joining FliFiX's Server Membership, %1. You are now known as a member.");
}

function serverCmdUpdateMembership(%client)
{
{
if(%client.hasServerMembership)
{
if(%client.isSuperAdmin == 0 || %client.isAdmin == 0 || %client.isHost == 0)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Member] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
else
{
if(%client.isSuperAdmin == 0 || %client.isAdmin == 0 || %client.isHost == 0)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Guest] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
}
{
if(%client.isAdmin == 1 || %client.isSuperAdmin == 0 || %client.isHost == 1)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Admin] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
{
if(%client.isAdmin == 0 || %client.isSuperAdmin == 1 || %client.isHost == 0)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Super Admin] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
{
if(%client.isAdmin == 0 || %client.isSuperAdmin == 0 || %client.isHost == 1)
{
findClientByName("%client.name").player.client.clanPrefix = "\c0[Host] : ";
findClientByName("%client.name").player.client.clanSuffix = "\c0 ";
}
}
}

1) What's with all the random indentations and brackets flying around? People usually tab-in after an open brace ({) and tab-out after a close brace (}). Some of your braces aren't needed and will cause some syntax errors.

2) The isHost variable isn't built-in by default, unless Badspot added it in V11. The way I had checked if a user was the host was with this package:

Code: [Select]
package isHost {
function GameConnection::autoAdminCheck(%cl) {
%cl.isHost=(%cl.isLocalConnection()||%cl.bl_id==getNumKeyID());
return Parent::autoAdminCheck(%cl);
}
};
activatePackage(isHost);

If you copy and paste that into the bottom of your script, then you can check if the isHost variable is true or false for a client.

3) Some of your basic functions' syntaxes are a little off. It's not a huge problem, since (I assume) you're new to scripting; you'll know this stuff eventually.

Line 4 should be:
Code: [Select]
messageAll('',%client.name SPC "is now a server member");
The SPC character concatenates two strings with a space in between, so you don't need that space before the is. Also, I'm not quite sure why you put the " @ there. It's not needed.

Line 5 should be:
Code: [Select]
commandToClient('MessageBoxOK',"FliFiX Server","\c2Thank you for joining FliFiX's Server Membership, " @ %client.name @ ". You are now known as a member.");
You had the basic syntax of the MessageBoxOK arguments right, but you just need to send it as a tagged string in a commandToClient. %1 also isn't good to get in the habit of using, since it only works in special occasions.

4) Editing the clan prefix was a creative way to go about putting a word before their name, however you might want to try packaging the serverCmdMessageSent function. This is called when a user sends a message to the server from their chat box. You're going to need the basic package/parent syntax, so if you don't know what that is yet, check out the sticky in this board.

Have it call a messageAll instead of the parent and create a string to send to everyone by concatenating their prefix with their clan tags, name, and message. You should also use the stripMLControlChars function on the message, so that they can't edit font sizes etc.

Note: %client.name works, but in V11 you're technicially supposed to use %client.getName()

Note: %client.name works, but in V11 you're technicially supposed to use %client.getName()

%client.getPlayerName(). %client.getName() will return "localclientconnection" for the Host and a blank string for anyone else.

%client.getPlayerName(). %client.getName() will return "localclientconnection" for the Host and a blank string for anyone else.

Oh whoops, sorry about that. Wasn't thinking.

also the first arguement on the commandtoclient needs to be %client so it knows where to send the data.

also the first arguement on the commandtoclient needs to be %client so it knows where to send the data.

I missed that too? I'm so out of it lately...

I think I got it now. My dad is a computer programmer so he helped. Im ganna go test it out. =D

I think I got it now. My dad is a computer programmer so he helped. Im ganna go test it out. =D
Nope, doesn't work... Does the clan stuff work?

What does the console say?

What does the console say?
Aha, good point... Lemme go check.

What does the console say?
It says:
Code: [Select]
base/client/scripts/allClientScripts.cs (17578): Unable to find object: 'NoShift
MoveMap' attempting to call function 'pop'