Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Haveing Trouble with a script im trying to make


Gareth556
 Share

Recommended Posts

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 Script
Case 0
    Dim Activetimes
Activetimes = 0
If Activetimes < 3
    Call Playermsg(Index, GetPlayername(Index) & " Leave Now Or You Will Be Jailed", RED)
    Activetimes = Activetimes + 1
Else
    Call Playermsg(Index, "You have been Jailed", RED)
    Call Globalmsg(GetPlayername(Index) & " Was Jailed")       
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 Select
End Sub
Link to comment
Share on other sites

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 bit

It Runs this continualy every time i step on the tile
    Dim Activetimes
Activetimes = 0
If Activetimes < 3 Then
    Call Playermsg(Index, GetPlayername(Index) & " Leave Now Or You Will Be Jailed", RED)
    Activetimes = Activetimes + 1

But it never moves onto this
Else
    Call Playermsg(Index, "You have been Jailed", RED)
    Call Globalmsg(GetPlayername(Index) & " Was Jailed", RED)       
End If
Exit Sub

No matter how many times i step on the tile
Link to comment
Share on other sites

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

Thank you for all your help
But 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

look If your new to scripting open data ini and change ScriptingErrors to 1,that would help you a little bit anyway back to topic

Put this line OnNewchar cuz otherwise the script wont work

Call 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 Select
End Sub

Maybe this one would be better

Sigait.
Link to comment
Share on other sites

@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

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?
Link to comment
Share on other sites

@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 again

Sigait.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...