Hallo,
wäre es möglich InGame im Chat mit einem Befehl z.B /tr einen Taschenrechner zu haben?
Hoffe ihr könnt mir helfen
Grüße
Hallo,
wäre es möglich InGame im Chat mit einem Befehl z.B /tr einen Taschenrechner zu haben?
Hoffe ihr könnt mir helfen
Grüße
wäre es möglich
Ja, wäre es.
Und wie? ![]()
Mit AHK ![]()
Ich hab das früher mal mithilfe einer kleinen aber nützlichen Funktion von Paul.Phoenix und der PlayerInput Funktion gelöst:
#If WinActive("GTA:SA:MP") && isInChat()
:?:/tr::
rechnung := PlayerInput("Rechne: ")
AddChatMessage("Das Ergebnis lautet: " Evaluate(rechnung))
return
PlayerInput(text){
KeyWait Enter
Send t^a{backspace}%text%
Input, var, v, {enter}
Send ^a{backspace}{enter}
Sleep, 20
return var
}
Evaluate(string) {
static sc := ComObjCreate("ScriptControl")
sc.Language := "JScript"
string := "a = " string ";"
sc.ExecuteStatement(string)
new := sc.Eval("a")
return new
}
Alles anzeigen
Ich hatte mal das hier gefunden:
stringMath(string) {
while(position := RegExMatch(string, "\(([^\(\)]+)\)", regex_)) {
string := RegExReplace(string, "\(([^\(\)]+)\)", stringMath(regex_1), blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_)) {
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_1 . regex_2**regex_3, blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\*|/) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_3 == "*")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\* *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2*regex_4, blahblah, 1, position)
if(regex_3 == "/")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) */ *((?:\+||)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2/regex_4, blahblah, 1, position)
}
while(position := RegExMatch(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\+|-) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_2 == "+")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\+ *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1+regex_3, blahblah, 1, position)
if(regex_2 == "-")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *- *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1-regex_3, blahblah, 1, position)
}
if(RegExMatch(string, "^-?\d+(?:\.\d+)?$"))
return string
return "ERROR"
}
Alles anzeigen
Einfach mit PlayerInput() machen. ZB so (Mit der SAMP.ahk![]()
#Include, SAMP.ahk
:?:/tr::
Suspend Permit
ergebnis := stringMath(PlayerInput("Taschenrechner: "))
addMessageToChatWindow("{FFFFFF}Ergebnis: {CCCCCC}" ergebnis)
return
stringMath(string) {
while(position := RegExMatch(string, "\(([^\(\)]+)\)", regex_)) {
string := RegExReplace(string, "\(([^\(\)]+)\)", stringMath(regex_1), blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_)) {
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_1 . regex_2**regex_3, blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\*|/) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_3 == "*")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\* *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2*regex_4, blahblah, 1, position)
if(regex_3 == "/")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) */ *((?:\+||)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2/regex_4, blahblah, 1, position)
}
while(position := RegExMatch(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\+|-) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_2 == "+")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\+ *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1+regex_3, blahblah, 1, position)
if(regex_2 == "-")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *- *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1-regex_3, blahblah, 1, position)
}
if(RegExMatch(string, "^-?\d+(?:\.\d+)?$"))
return string
return "ERROR"
}
PlayerInput(text){
s := A_IsSuspended
Suspend On
KeyWait Enter
BlockChatInput()
SendInput t^a{backspace}%text%
Input, var, v, {enter}
SendInput ^a{backspace 100}{enter}
Sleep, 20
UnblockChatInput()
if(!s)
Suspend Off
return var
}
Alles anzeigen