Jump to content

Problem in Command


Nicorotom

Recommended Posts

Hello,

today i have created a client-side-script.

Now i have transfered the Commands from the server-side-script to the client-side-script.

But now i have a Problem with one of the Commands.

Here is the Command:

function alogin(passwort)
if(passwort=="haha")
then
	admin_eingeloggt=true
outputChatBox("#00FF00Erfolgreich eingeloggt!",255,255,255,true)
else
outputChatBox("#FF0000Falsches Passwort!",255,255,255,true)
end
end

Command Handler:

addCommandHandler("alogin",alogin)

But when i enter the Command /alogin haha the server says: "Falsches Passwort!"

Why is this so?

Where is the Wrong Code?

Thanks

Greetings,

Nicorotom

Edited by Guest
Link to comment

So, the login is fixed.

Now i have another problem:

function avehicle(avehicle,model)
if(admin_eingeloggt==true)
then
local x,y,z=getElementPosition(getLocalPlayer())
local r=getPedRotation(getLocalPlayer())
	y=y+5
local vehiclename=getVehicleModelFromName(model)
local vehicle=createVehicle(vehiclename,x,y,z)
setVehicleRotation(vehicle,0,0,r)
outputChatBox("#00FF00Vehicle mit dem Namen "..model.." gespawnt!",255,255,255,true)
else
outputChatBox("#FF0000Du bist nicht als Admin eingeloggt!",255,255,255,true)
end
end

Handler:

addCommandHandler("avehicle",avehicle)

The Vehicle spawns, but i can't enter them

Also when i use

setVehicleLocked(vehicle,false)

i can't enter the Vehicle!

Link to comment

Just one thing about that admin login. Maybe it was just an excercise to learn scripting, but you should be aware that clientside scripts are not safe for that kind of things. That password could simply be read by looking at the script, since it is downloaded to each player. They are stored in MTA\mods\deathmatch\resources. Clientside scripts should never be used to do anything security related.

Link to comment
So, which Commands must be in a Server-Script an which in a Client-Script?

all things that need to be synced should be done server side, and all things that no need to be synced - clientside.

note that not all functions available client-side are avaiable server-side and vice versa

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...