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

Is this code correct?


Dark Knight
 Share

Recommended Posts

Hey guys, I'm a bit of a noob at Eclipse. But I was wondering, how do I get this code to work? **I went out on the edge here and tried to code this myself.** - So please correct me on this code.

**What is the purpose of this code?**

I want this code to give people points when you do: **/givep playername**
**Where is the code located?**

The bottom of Main.txt

Code:

```
Case "/givep"
                                      PlayerID = FindPlayer(TextSay(1))
If GetPlayerAccess(Index) > 0 Then
                                                Call PlayerMsg(Index, "You don't have enough rights to do this command!", RED)
                                    Else
                                    If SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 5)
                        End Case

```
Link to comment
Share on other sites

Wait, it isn't working. Do I have it in the right place?

Edit: Keeps saying it's an Invalid Command now.

' Executed whenever a slash command is sent to the server.
Sub Commands(Index)
Dim TextSay
Dim PlayerID
Dim MapNum

' Get the command and arguments from the cache.
TextSay = Trim(GetVar("Scripts\Command.ini", "TEMP", "Text" & Index))

' Split the command into an array. All arguments are seperated by spaces.
TextSay = Split(TextSay)

Select Case TextSay(0)
Case "/testscripts"
Call TestMain(Index)
Exit Sub

Case "/help"
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, "'msghere = Broadcast Message", WHITE)
Call PlayerMsg(Index, "-msghere = Emote Message", WHITE)
Call PlayerMsg(Index, "!namehere msghere = Player Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh", WHITE)
Exit Sub

Case "/calladmins"
If GetPlayerAccess(Index) = 0 Then
Call AdminMsg(GetPlayerName(Index) & " needs your help!", BRIGHTGREEN)
Else
Call PlayerMsg(Index, "You are an admin! You cannot call for help!", BRIGHTGREEN)
End If
Exit Sub

Case "/admin"
If GetPlayerAccess(Index) > 0 Then
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, """msghere = Global Admin Message", WHITE)
Call PlayerMsg(Index, "=msghere = Private Admin Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /admin, /loc, /mapeditor, /warpmeto, /warptome, /warpto, /setsprite, /mapreport, /kick, /ban, /edititem, /respawn, /editnpc, /motd, /editshop, /ban, /editspell", WHITE)
End If
Exit Sub

Case "/warpmeto"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(Index, GetPlayerMap(PlayerID), GetPlayerX(PlayerID), GetPlayerY(PlayerID))
Call PlayerMsg(Index, "You have been warped to " & GetPlayerName(PlayerID) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warptome"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(PlayerID, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(PlayerID, "You have been warped to " & GetPlayerName(Index) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warpto"
If GetPlayerAccess(Index) > 0 Then
MapNum = TextSay(1)

If MapNum > 0 And MapNum <= MAX_MAPS Then
Call PlayerWarp(Index, MapNum, GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(Index, "You have been warped to map #" & MapNum & ".", BRIGHTBLUE)
Else
Call PlayerMsg(Index, "Invalid map number.", BRIGHTRED)
End If
End If
Exit Sub

                                    Case "/givep"
                                                    PlayerID = FindPlayer(TextSay(1))
                                              If GetPlayerAccess(Index) = 0 Then
                                                                                                  Call PlayerMsg(Index, "You don't have enough rights to do this command!", RED)
  Else
      Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 5)
  End If
End Select

Call PlayerMsg(Index, "That is not a valid command.", BRIGHTRED)
End Sub
Link to comment
Share on other sites

You should add Exitsub

Case "/givep"
  PlayerID = FindPlayer(TextSay(1))
  If GetPlayerAccess(Index) = 0 Then
      Call PlayerMsg(Index, "You don't have enough rights to do this command!", RED)
  Else
      Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 5)
  End If
Exit Sub

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...