Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Voting Script [Help] (https://forums.graalonline.com/forums/showthread.php?t=134266970)

Bleachlover551 08-11-2012 01:05 AM

Voting Script [Help]
 
Okay so im completelly lost here i need this to be for every player.
like players can only vote once per day.

Script:
PHP Code:

function onPlayerchats() {
  if (
player.chat == "/yes") {
      
player.chat "Fp4:Yes!";
      
server.votes += 1;
      
updateChat();
}
}
function 
updateChat() {
  
this.chat "Votes: " server.votes;


I know im not that good at stuff like this lol but if u can help me out. i would love you forever ;)

Tricxta 08-11-2012 04:12 AM

So what you'll do is you'll have to make use of a server time variable "timevar"/"timevar2" store that in a client string and then when the player comes to vote again, compare the distance between the current time and the recorded time, if it's greater than 24 hours let them vote again.

PHP Code:

function onPlayervotes(){
  if (
timevar2 clientr.voteTime >= 24*360){
    
server.votes ++;
    
clientr.voteTime timevar2;
    return 
true;
  }
  else return 
false;


Of course to set a clientr variable you must be on the serverside and there you wouldn't have the player scope so you still have some work to do.
Good luck.

cbk1994 08-11-2012 05:53 AM

Quote:

Originally Posted by Tricxta (Post 1701586)
you must be on the serverside and there you wouldn't have the player scope

In level NPC scripting it's fairly rare for the player not to be in scope. Just use onPlayerChats serverside and use the player scope it provides.


All times are GMT +2. The time now is 10:57 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.