Gareth556 Posted September 5, 2009 Author Share Posted September 5, 2009 Im Not Sure what im doing wrong what i am trying to make the script do is warn someone that thay are in a restricted area or whatever then warp them to a jail im kinda just messing around with scripts to get my head around the sadscript side of things and was intending to add something to warp the player once i got the script to run properly but for some reason the script will not run at all and im not sure why here is my scripted tile section case 0 is where i am trying to get the script to run' Executes when a player steps onto a scripted tile.Sub ScriptedTile(Index, Script)Select Case ScriptCase 0 Dim ActivetimesActivetimes = 0If Activetimes < 3 Call Playermsg(Index, GetPlayername(Index) & " Leave Now Or You Will Be Jailed", RED) Activetimes = Activetimes + 1Else Call Playermsg(Index, "You have been Jailed", RED) Call Globalmsg(GetPlayername(Index) & " Was Jailed") End IfExit SubCase ElseCall PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)Exit SubEnd SelectEnd Sub Link to comment Share on other sites More sharing options...
balliztik1 Posted September 5, 2009 Share Posted September 5, 2009 > Call Globalmsg(GetPlayername(Index) & " Was Jailed", COLOR) Link to comment Share on other sites More sharing options...
Gareth556 Posted September 5, 2009 Author Share Posted September 5, 2009 Added a colour to the Call Globalmsg still won't work i place a scripted tile on a test map selected script 0 and also placed a second tile with script 1 the script will not run when i step on it tho Link to comment Share on other sites More sharing options...
balliztik1 Posted September 5, 2009 Share Posted September 5, 2009 > If Activetimes < 3 ThenDidn't see that one first time through. :cry: Link to comment Share on other sites More sharing options...
Gareth556 Posted September 5, 2009 Author Share Posted September 5, 2009 Added Then but the script only runs the first section dosent seem to add anything to Activetimes it is supposed to warn the player 3 times and then move on to the 2nd bitIt Runs this continualy every time i step on the tile Dim ActivetimesActivetimes = 0If Activetimes < 3 Then Call Playermsg(Index, GetPlayername(Index) & " Leave Now Or You Will Be Jailed", RED) Activetimes = Activetimes + 1But it never moves onto thisElse Call Playermsg(Index, "You have been Jailed", RED) Call Globalmsg(GetPlayername(Index) & " Was Jailed", RED) End IfExit SubNo matter how many times i step on the tile Link to comment Share on other sites More sharing options...
balliztik1 Posted September 5, 2009 Share Posted September 5, 2009 Oh, yeah. I didn't even look at the content. I just checked out the syntax. You'll have to use either public variables, or GetVar/Putvar. You are setting Activetimes to 0 every time you run the script, so it will never get above 3\. Try using GetVar and PutVar:```Call PutVar("something.ini", GetPlayerName(index), "Activetimes", CStr(CLng(GetVar("something.ini", GetPlayerName(index), "Activetimes")) + 1))``` Link to comment Share on other sites More sharing options...
Gareth556 Posted September 5, 2009 Author Share Posted September 5, 2009 Thank you for all your helpBut it is still not working and somehow i think the problem is more that i don't know enough about sadscript just yet im sure i will get this working but for now i might use Eclipse angel's /jail command and do some more reading up on sadscript and how it all works and mabey fix this script at a later date when i know more about scripting with sadscript Link to comment Share on other sites More sharing options...
Sigait Posted September 5, 2009 Share Posted September 5, 2009 look If your new to scripting open data ini and change ScriptingErrors to 1,that would help you a little bit anyway back to topicPut this line OnNewchar cuz otherwise the script wont workCall PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 0)Sub ScriptedTile(Index, Script) Select Case Script Case 0 If GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") = 0 Then Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 1) End If If GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") < 3 Then Call Playermsg(Index, GetPlayername(Index) & " Leave Now Or You Will Be Jailed", RED) Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") + 1) Else Call Playermsg(Index, "You have been Jailed", RED) Call Globalmsg(GetPlayername(Index) & " Was Jailed", 0) End If Exit Sub Case Else Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE) Exit Sub End SelectEnd SubMaybe this one would be betterSigait. Link to comment Share on other sites More sharing options...
balliztik1 Posted September 5, 2009 Share Posted September 5, 2009 ```Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 1)```You don't want to set it each time you run the script. That puts you in the same situation as the original script.Also, you forgot the GlobalMsg color, too. Link to comment Share on other sites More sharing options...
Sigait Posted September 5, 2009 Share Posted September 5, 2009 @Balliztik1:> ```> Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 1)> ```> You don't want to set it each time you run the script. That puts you in the same situation as the original script.> > you're right> > Sigait.> > Also, you forgot the GlobalMsg color, too. Link to comment Share on other sites More sharing options...
Gareth556 Posted September 5, 2009 Author Share Posted September 5, 2009 that works perfectly Sigait thank youone quick question tho in this section:Case 0 If GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") = "" Then Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 1) End Ifim not sure if i understand what is happening here is the script checking to see if jail.ini has the varible Activetimes then putting the varible there if it is not there with the value of 1? Link to comment Share on other sites More sharing options...
Sigait Posted September 5, 2009 Share Posted September 5, 2009 @Gareth556:> that works perfectly Sigait thank you> > one quick question tho in this section:> Case 0> If GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") = "" Then> Call PutVar("jail.ini", GetPlayerName(index), "ActiveTimes", 1)> End If> > im not sure if i understand what is happening here is the script checking to see if jail.ini has the varible Activetimes then putting the varible there if it is not there with the value of 1?I wasent pretty sure bout this line :"If GetVar("jail.ini", GetPlayerName(index), "ActiveTimes") = "" Then" since the ini wasent created and i thought this wont work so i modified it,but if it worked the first time then with this line of code ok.Anyway that was the basic meaning of it,to see if the inihad numbers or not this way it wouldnt make that 1 again and again and againSigait. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now