|
Ilnair
|
 |
« on: June 23, 2006, 10:19:29 AM » |
|
Ok, I created a script to allow people to buy a "generated key" (or whatever), on you site, and then they can credit it ingame by typing /credit <key>. When they do so, they gain an item, a member status, nothing, a guild, or whatever, thats up to you, i'm just giving you the script.
Difficulty: New Scripters: 5/5 Advanced scripters: 2/5 Vets: 0/5 Me: I wrote it, ofcourse i'm able to use it, smartass.
Please note. If you want to be sure the script cannot be cracked, you will have to edit the script on the location marked with <CHANGE VALUE HERE BETWEEN 1111 and 9999>
A key can only be used 1 time, the script saves all used keys to a .ini file. If an admin wants to, they can use /credit check <key> to check a key for validity, if it's valid it will also check if it has been previously used. If so, it will give the account details (ip/login name/charname/charnum) of the person that used it.
Commands: /credit ... ... <key> credit a key ... check <key> (admin only), checks a key if it's valid ... generate (admin only), will generate a random key
Insert the following functions at the bottom of you main.txt:
'************************************************ 'START CREDITS SYSTEM! Dinand Mentink - Ilnair '************************************************ Function CheckCredit(index, code1, code2) On Error Resume Next CheckCredit = 0 If CryptCode(index, code1) = code2 Then CheckCredit = 1 Else CheckCredit = 0 Exit Function End If
If GetVar("credit.ini", "prevuse", code1 & "") = 0 Then CheckCredit = 1 Else CheckCredit = 2 End If End Function
Function CryptCode(index, code1) Dim code1temp code1temp = code1 code1temp = 1/(Log(code1temp)/10) code1temp = 1.6 * code1temp
code1temp = code1temp / (<INSERT NUMBER BETWEEN 1111 and 9999>^0.5)
code1temp = code1temp * 25 code1temp = Log((code1temp^<INSERT NUMBER BETWEEN 1 and 1.5)+1)
code1temp = (code1temp - 0.25) * 10 code1temp = code1temp * 10000000000 CryptCode = Int(code1temp) End Function
'************************************************ 'END CREDITS SYSTEM! Dinand Mentink - Ilnair '************************************************
Insert the following command:
If LCase(Mid(TextSay, 1, 7)) = "/credit" Then If Len(TextSay) > 8 Then If Mid(TextSay, 9, 5) = "check" Then If GetPlayerAccess(index) = 0 Then Call PlayerMsg(index, "You have to be a GM to use this command!", 12) Exit Sub End If TextSay = Mid(TextSay, 14) code1 = Int(LCase(Mid(TextSay, 1, 9))) code2 = Int(LCase(Mid(TextSay, 11, 13))) If CheckCredit(index, code1, code2) = 0 Then Call PlayerMsg(index, "Diamond Code: " & code1 & "-" & code2 & " is invalid!", 12) Exit Sub ElseIf CheckCredit(index, code1, code2) = 1 Then Call PlayerMsg(index, "Diamond Code: " & code1 & "-" & code2 & " is valid and has not been used before!", 10) Exit Sub Else Call PlayerMsg(index, "Diamond Code: " & code1 & "-" & code2 & " is valid, but has been used before!", 14) n = GetVar("credit.ini", "prevuseinfo", code1 & "") Call Playermsg(index, "Details: " & n, 15) Exit Sub End If
Exit Sub End If
TextSay = Mid(TextSay, 8) Select Case LCase(Trim(TextSay)) Case "help" If GetPlayerAccess(index) > 0 Then Call PlayerMsg(index, "COMMAND REFERENCE for /credit:", 15) Call PlayerMsg(index, "This command is used to credit diamond codes!", 15) Call PlayerMsg(index, "Commands: <diamond code>: This will credit a diamond into your inventory!", 15) Call PlayerMsg(index, " check: Checks a code for details!", 15) Call PlayerMsg(index, " generate: Generates a random Diamond Code!", 15) Exit Sub Else Call PlayerMsg(index, "Help for /credit:", 15) Call PlayerMsg(index, "This command is used to credit diamond codes!", 15) Call PlayerMsg(index, "Commands: <diamond code>: This will credit a diamond into your inventory!", 15) Exit Sub End If
Case "generate" If GetPlayerAccess(index) = 0 Then Call PlayerMsg(index, "You have to be a GM to use this command!", 12) Exit Sub End If
code1 = Int((99999999 - 10000000 + 1)*Rnd) + 10000000 code2 = CryptCode(index, code1) Call PlayerMsg(index, "Generated Diamond Code: " & code1 & "-" & code2, 15) n = 1
Do While n < 11 code1 = Int((99999999 - 10000000 + 1)*Rnd) + 10000000 code2 = CryptCode(index, code1) Call PutVar("codes.ini", "Generated Codes", "Code" & n & " ", " " & code1 & "-" & code2) n = n + 1 Loop Exit Sub End Select code1 = Int(LCase(Mid(TextSay, 1, 9))) code2 = Int(LCase(Mid(TextSay, 11, 13)))
If code1 > 9999999 and code1 < 100000000 Then If CheckCredit(index, code1, code2) = 0 Then Call PlayerMsg(index, "The code you entered: " & code1 & "-" & code2 & " is invalid!", 12) Exit Sub ElseIf CheckCredit(index, code1, code2) = 1 Then Call PlayerMsg(index, "The code you entered: " & code1 & "-" & code2 & " is valid!", 10) '<INSERT WHAT YOU WANT TO HAPPEN HERE!> Call PutVar("credit.ini", "prevuseinfo", code1 & "", "Account: " & GetPlayerLogin(index) & " CharNum: " & GetPlayerCharNum(index) & " IP: " & GetPlayerIP(index) & " Character Name: " & GetPlayerName(index)) Call PutVar("credit.ini", "prevuse", code1 & "", "1") Exit Sub Else Call PlayerMsg(index, "The code you entered: " & code1 & "-" & code2 & " is valid, but has been used before! Please contact a GM if you are sure you didn't already use this code!", 12) Exit Sub End If End If
Call PlayerMsg(index, "This command does not exist. Please enter /credit help for all commands.", 12) Else 'Dit gebeurt er als je niets invult achter het commando Call PlayerMsg(index, "You need to enter a subcommand. Please enter /credit help for all commands.", 12) End If Exit Sub End If
Ok, a code will look something like this: 12345678-123456789123
Please tell me if you get it to work!
|