| Blockland Forums > Modification Help |
| messageclient(); does not work? |
| << < (4/6) > >> |
| deathrider:
--- Quote from: Ipquarx on April 07, 2012, 09:26:04 PM ---Use gameConnection::onClientEnterGame. But parent it, and package it. --- End quote --- how do you know these is there like a list? |
| Nexus:
--- Quote from: deathrider on April 08, 2012, 02:47:37 AM ---i think it needs to be ' as /c6 is a command if i have read right from other scrips this one i learnt from cell phone mod --- End quote --- It isn't a command, its just a text modifier. A command would be something like: commandtoclient(%client, 'bottomprint', "<font:impact:18>\c2text goes here", 5); the bottomprint here is a command, and then the string goes in regular quotes. It is called tagging a string, and using apostrophes can have weird results like it sending the player numbers representing the command instead of words that the client can understand. |
| deathrider:
--- Quote from: Nexus on April 08, 2012, 08:52:34 AM ---It isn't a command, its just a text modifier. A command would be something like: commandtoclient(%client, 'bottomprint', "<font:impact:18>\c2text goes here", 5); the bottomprint here is a command, and then the string goes in regular quotes. It is called tagging a string, and using apostrophes can have weird results like it sending the player numbers representing the command instead of words that the client can understand. --- End quote --- ok, i need someone to show me how to use the if thing like if(%client.isadmin) and have an exsample thats how i learn exsample and looking at differences heres my new one i dont know if the if things are right --- Code: ---package AutoMessage { function GameConnection::onconnect(%client) { %name = findclientbyname(%client); %random = getrandom(0, 4); if(%random == "1") { commandtoserver('messagesent',"Hey " @ %name @ " how ya going.); return; } if(%random == "2") { commandtoserver('messagesent',"Whats up" @ %name @ "."); return; } if(%random == "3") { commandtoserver('messagesent',"Welcome to my server" @ %name @ "."); return; } if(%random == "4") { commandtoserver('messagesent'."Yay more people are joining"); return; } parent::onconnect(%client) } activatepackage (AutoMessage); --- End code --- |
| Nexus:
--- Quote from: deathrider on April 08, 2012, 09:30:14 AM ---ok, i need someone to show me how to use the if thing like if(%client.isadmin) and have an exsample thats how i learn exsample and looking at differences heres my new one i dont know if the if things are right --- Code: ---package AutoMessage { function GameConnection::onconnect(%client) { %name = findclientbyname(%client); %random = getrandom(0, 4); if(%random == "1") { commandtoserver('messagesent',"Hey " @ %name @ " how ya going.); return; } if(%random == "2") { commandtoserver('messagesent',"Whats up" @ %name @ "."); return; } if(%random == "3") { commandtoserver('messagesent',"Welcome to my server" @ %name @ "."); return; } if(%random == "4") { commandtoserver('messagesent'."Yay more people are joining"); return; } parent::onconnect(%client) } activatepackage (AutoMessage); --- End code --- --- End quote --- There are a couple of problems with this. You are getting your client side code and your server side code mixed up. This will only work if you are hosting a non-dedicated server. Also just stacking if statements for essentially the same test isn't the best way to do it. Other than that this should work fine. edit: oh also don't have a return before the parent::onconnect The parent should be the very first thing in this kind of function anyway. |
| Port:
--- Quote from: Nexus on April 07, 2012, 10:50:01 PM ---you should use regular "quotes" instead of 'apostrophes' around the words you want people to read, because apostrophes work differently. Honestly I myself don't really understand it entirely, but generally: If you are sending a command, it goes in apostrophes. If you are sending a string for the player to read, it goes in quotes. If someone could clarify it better that would be nice. --- End quote --- Over the network, a string typed in quote marks is sent by first specifying the length of the string followed by the raw string itself. This can be quite slow, which is bad for things that need to run quickly, such as notifications of events, kill messages or other things. When you type a string in apostrophes, it means that it's a tagged string. A tagged string is not sent as the string itself, rather as a number identifying it. The first time you send a tagged string over the network, it is given a unique ID and sent in full length, however all future transmissions only contain the ID. This allows for much faster transmission of strings that may be repeated often, such as command names or kill messages. In TorqueScript, typing echo( 'hello' ); will display the ID of the tagged string. If you want to see the actual string itself, use echo( getTaggedString( 'hello' ) ); getTaggedString( index ) converts a tagged string ID to the string itself. If you're going to do a loop on this which ends once you reach an empty string, note that index 0 is always taken up by an empty string (length 0). getTag( string ) converts a string to a tagged string ID representing it. Here's some things that you have to (bolded), really should (italics) or it could be a good idea to send as tagged strings: Network commands (clientCmd, serverCmd, secureClientCmd) Kill messages Player names (as arguments to messageClient, use getTag for this) Repeating messages, generally fixed messages with changing arguments (e.g. round win notifications.). Here's some things that you shouldn't use tagged strings for: Chat messages Large streams of data |
| Navigation |
| Message Index |
| Next page |
| Previous page |