Jump to content

Qudditch Ring Script -- why is it spamming scores?


Glanecia Varriale
 Share

You are about to reply to a thread that has been inactive for 3189 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I was super excited to be given this script. However, it's not working properly and the creator of the script hasn't been on to answer questions -- not complaining though, he's letting me use this, so yay. The trouble is, it keeps spamming the score. I have no idea how to script. Can someone look at this and tell me why it might be spamming scores by ten once the quaffle is sent through just once? It's supposed to keep track of the score, every time the quaffle is thrown through ... but instead it's just counting up by tens repeatedly. 

Here's the script: 

 

string ringLocation="n" ; //Set to "s" for south ring, "n" for north ring
integer iScore = 0;
string sTeam = "";
list lOptions = ["Select Team","Reload Ref List"];
list lTeams = ["Gryffindor","Hufflepuff","Ravenclaw","Slytherin", "Reset"];
integer REFHUD=-720 ;
key playerKey = NULL_KEY ;

list lAllowed = [];
string gName;
integer gLine = 0;
key gQueryID;
key requestid;
list lQueue = [];
integer scorecheck = 0 ; //ADDED

Web_QueueMsg(integer ToDo, string sText)
{
lQueue += [(string)ToDo + sText];
}

Web_UpdateScore(string sText)
{
requestid = llHTTPRequest("http://dhome.sytes.net/twoh/twoh_quidditch_score.php",
[HTTP_METHOD, "POST",
HTTP_MIMETYPE, "application/x-www-form-urlencoded"],sText);
}

Web_SaveLog(string sText)
{
requestid = llHTTPRequest("http://dhome.sytes.net/twoh/twoh_quidditch_log.php",
[HTTP_METHOD, "POST",
HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
"log=" + sText);
}

Refresh()
{
llSetText(sTeam + " Score: " + (string)iScore, <1.0,1.0,1.0>, 1);
integer iTeam = llListFindList(lTeams,[sTeam]) + 1;
llRegionSay(-120985,ringLocation + (string)iTeam + (string)iScore);
}

integer IsAllowed(string name)
{
return llListFindList(lAllowed,[llToLower(name)]);
}

default
{
state_entry()
{
llVolumeDetect(TRUE);

gName = llGetInventoryName(INVENTORY_NOTECARD, 0);
gQueryID = llGetNotecardLine(gName, gLine);

llSetText("Touch me to setup", <0,1,0>, 1);
llListen(-22, "", NULL_KEY, ""); //Dialog Channel
llListen(-1999, "", NULL_KEY, ""); //Ref Channel

llListen(-7899, "", NULL_KEY, ""); //Quaffle info channel
scorecheck = 0 ; //ADDED


//llSetTimerEvent(2);
}

on_rez(integer start_param)
{
llResetScript();
}

touch_start(integer n)
{
if (IsAllowed(llKey2Name(llDetectedKey(0))) < 0) return;
llDialog(llDetectedKey(0), "Select Option ...", lOptions, -22);
}


dataserver(key query_id, string data)
{
if (query_id == gQueryID)
{
if (data != EOF)
{
lAllowed += [llToLower(data)];
++gLine;
gQueryID = llGetNotecardLine(gName, gLine);
}
else
llSay(0,"Ref List Updated");
}
}

listen(integer channel, string name, key id, string message)
{
if ((channel == 7899) && (message=="QCATCH")) {
// QCATCH tells us the keeper caught the quaffle. No goals allowed
scorecheck=1 ;
}
if (channel == -1999)
{
//**Ref Commands**
string sMsg = llGetSubString(message,0,0);
key kRef = (key)llDeleteSubString(message,0,0);
string sRef = llKey2Name(kRef);

if (IsAllowed(sRef) < 0) return;

if (sMsg == "n")
{
iScore -= 10;
//Web_QueueMsg(1,"team=" + sTeam + "&score=" + (string)iScore);
//Web_QueueMsg(2,sRef + ": Ref Command, Null Goal");
Refresh();
llShout(0, "A goal has been invalidated by " + sRef + " to " + sTeam + " Team.");
return;
}
else if (sMsg == "r")
{
iScore = 0;
//Web_QueueMsg(1,"team=" + sTeam + "&score=" + (string)iScore);
//Web_QueueMsg(2,sRef + ": Ref Command, Reset Score");
Refresh();
llShout(0, sTeam + " Score has been reset");
return;
}
else if (sMsg == "g")
{
iScore += 10;
//Web_QueueMsg(1,"team=" + sTeam + "&score=" + (string)iScore);
//Web_QueueMsg(2,sRef + ": Ref Command, Add Goal");
Refresh();
llShout(0, "A goal has been added by " + sRef + " to " + sTeam + " Team.");
return;
}
else
return;
}
else if (channel == REFHUD) {
if (llGetSubString(message,0,9)=="Keeper Com") {
string sText="That's a keeper shooting at the rings!!" ;
llShout(0, sText);
llRegionSay(-735, sText);
}
}
else if (channel == -22)
{
//**Dialog Commands**
if (llListFindList(lOptions + lTeams, [message]) != -1)
{
if (message == "Reload Ref List")
{
gLine = 0;
lAllowed = [];
gName = llGetInventoryName(INVENTORY_NOTECARD, 0);
gQueryID = llGetNotecardLine(gName, gLine);
return;
}
else if (message == "Select Team")
{
llDialog(id, "Select Team ...", lTeams, -22);
return;
}
else if (message == "Reset")
{
iScore = 0;
lQueue = [];
sTeam = "";
llSetText("Touch me to select the Team", <0,1,0>, 1);
return;
}
else
{
if (sTeam != "")
{
llSay(0,"You must reset me first");
return;
}
else
{
sTeam = message;
Refresh();
}
}
}
}
}

collision_start(integer num_detected)
{
if (sTeam == "") return;

if (llDetectedName(0) == "quaffle")
{
// Detect whether the keeper has the quaffle
// Did the keeper score?
playerKey=llDetectedKey(0) ;
llListen(REFHUD, "", playerKey, ""); //Ref HUD Channel
llSay(REFHUD,"RPCOM") ;
llSetTimerEvent(1); // 1 second should be enough. Check.

 

}

}

timer()
{
// Fired by collision

if (scorecheck==0) {
iScore += 10;

//Web_QueueMsg(1,"team=" + sTeam + "&score=" + (string)iScore);

string sText = llKey2Name(playerKey) +" Scored!! " + sTeam + " Score: " + (string)iScore;

//Web_QueueMsg(2,sText);
llShout(0, sText);
llRegionSay(-735, sText);

llShout(-7899, "REZQUAFFLE" +(string)playerKey);
llListenRemove(REFHUD) ;

Refresh();

}

// These updates seem to be disabled.
//if (lQueue = []) return;
//string sTmp = llList2String(lQueue,0);
//if (llGetSubString(sTmp,0,0) == "1")
//{
// Web_UpdateScore(llDeleteSubString(sTmp,0,0));
// lQueue = llDeleteSubList(lQueue,0,0);
//}
//else
//{
// Web_SaveLog(llDeleteSubString(sTmp,0,0));
// lQueue = llDeleteSubList(lQueue,0,0);
//}
}
}

Link to comment
Share on other sites

Your scripter forgot to turn off the timer.  You'll just have to add one line to do that. Look in the timer event near the end of the script.

timer(){// Fired by collision    if (scorecheck==0) {        iScore += 10;    //Web_QueueMsg(1,"team=" + sTeam + "&score=" + (string)iScore);        string sText = llKey2Name(playerKey) +" Scored!! " + sTeam + " Score: " + (string)iScore;    //Web_QueueMsg(2,sText);        llShout(0, sText);         llRegionSay(-735, sText);        llShout(-7899, "REZQUAFFLE" +(string)playerKey);        llListenRemove(REFHUD) ;        Refresh();        llSetTimerEvent(0.0);  //  <<<<  This is the line you need to add     }    // You can delete all of the lines after this that start with "//".     // They aren't being used anyway.}
Link to comment
Share on other sites

It already does that....

string sText = llKey2Name(playerKey) +" Scored!! " + sTeam + " Score: " + (string)iScore;//Web_QueueMsg(2,sText);llShout(0, sText);

If you want to learn to script, this is the place to come.  We're always glad to answer questions or offer suggestions about a script you are working on.  If you're looking for a scripter or a ready-made script, though, you really should be looking in the InWorld Employment forum or the Wanted forum.  In this case, you really should be talking with your own scripter, who wrote this one. :smileywink:

 

Link to comment
Share on other sites

yeah, the scripter that wrote this one doesn't have any plans on logging in reguarly I think .... but it doesn't actually say that the avatar scored when you score, it just says "Scored!"  ... and then 10 points  ..... I'll ask around, ty for your help ... and yes, I'd like to eventually learn how to script

Link to comment
Share on other sites

looks like either the quaffle channel or refhud channel would be

queried for the last person to have the quaffle?  not sure how the game

 works, but if the quaffle can be "passed" the name of the person holding it

 could be checked and that info queried after a goal?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3189 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...