![]() |
emoticons event
having some trouble here. I haven't scripted in quite a long time and I'm trying to make an event but I'm not sure where to start.
basically I'm trying to make the emoticons event, where an NPC does an emoticon and the players have to replicate the exact emoticon in a certain amount of time or else they get kicked. basically what I did, I put everything in a class. every time the player in the level used an emoticon, it set a client string with "emoticonchar" the NPC ran a 3 second loop using schedule event and every 3 seconds it would choose a random number between 65 and 90? (not sure if it was 90) since emoticonchar is basically just a value 65 - 90. when it picked the number it would add to a string. basically after 3 seconds it tries to match up the last emoticon value with your client string value. if it was different, it would kick you (I never really got to code this without it being buggy..) I don't have the code right now, but what I did seemed messy and it was quite buggy. the 3 second loop wasn't even working for some reason. is there a better way to do what I'm trying to accomplish? I'll try to re-do the code and show it here in a bit. |
Hmm....
Why save every player's emoticons that are pressed in a client string? You can just check everytime the player makes an emoticon if it's the correct one and if yes, add them to an array. at the end you loop throught the players and kick the ones that are not in that array |
Did you do this all serverside or clientside?
emoticonchar I don't think is serverside and if the check was made clientside, there's no need to check anyone else's emoticonchar other then the main player's (player variable) since everyone player will have their own instance of the clientside script running on their own computer (very nature of clientside scripting). You could just do a simple 0.05 timeout that checks player.emoticonchar against the npcs and it triggeraction's the result to the serverside if emoticonchar isn't either a null value (or whatever the value is when the player has no emoicon) or this.lastemoticon. Make sure to set this.lastemoticon = player.emoticonchar if the check is successful too to avoid spamming the npcserver with emoticons. The actual selecting of the emoticon should be done serverside (so everyone gets the same emoticon as well as picking who gets kept and who gets kicked (which is convenient since you can only warp players serverside). Hope this makes sense and helps you. |
this is what I came up with so far but it doesn't want to work.
PHP Code:
|
Quote:
If you are using the serverr variable to say tell the server the event is going on, then maybe that's a viable solution but personally, I would just trigger() or call a function of some core events WNPC for setting such a thing. The real bane I find with classic servers (where I feel they fall short) is that scripters attach a million and a half client. and clientr. variables to the player which can really slow down the loading time of the server (3/4 of the variables aren't even needed to be saved). server. and serverr. aren't so bad but I still tend to avoid them unless I have to use them. There's almost always a better method :) Anyways back to your script, the triggeractions will tell the serverside script when a player has a new emoticon. You could do like: PHP Code:
PHP Code:
That help? Also, how does array.index not work in an array? I've never found it not to work unless I'm using it wrong. |
You should've read my post :[
|
All times are GMT +2. The time now is 02:14 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.