Jump to content

Has player driving licence?


Recommended Posts

Posted

Hey. I wanted to make a script, which looks, if a file with the player's name already exists.

usage: /setlicence playername 1/0

playername = target, which we wanna give (1) or remove (0) the driving licence. If a file with his name exists in this folder,

there comes a fitting message. My script is serverside, and gives no errors... but I don't get a message, if it worked, and I can't delete or add my driving licence either...

how = 0 or 1

  
function setLicence( playerSource, command, target, how ) 
how = how 
if how then 
    targetsource = getPlayerFromName(target) 
    adminname = getPlayerName(playerSource) 
    accountName = getAccountName(getPlayerAccount(playerSource)) 
    if isObjectInACLGroup("user."..accountName , aclGetGroup("Admin")) then 
        if (fileExists(":wangcars/licences/"..target..".txt")) then 
            local fileHandle = fileOpen(":wangcars/licences/"..target..".txt") 
    if fileHandle then 
    end 
        end 
            if (fileExists(":wangcars/licences/"..target..".txt")) and (how == 1) then 
                outputChatBox( "The player already has a driving licence.", playerSource, 255, 0, 0 ) 
            elseif (fileExists(":wangcars/licences/"..target..".txt")) and (how == 0) then 
                fileDelete(fileHandle) 
                outputChatBox("You deleted the driving licence of "..target".", playerSource, 0, 255, 0 ) 
                outputChatBox("Your driving licence has been deleted by "..adminname.."!", targetSource, 255, 0, 0 ) 
            elseif not (fileExists(":wangcars/licences/"..target..".txt")) and (how == 1) then 
                fileHandle = fileCreate(":wangcars/licences/"..target..".txt") 
                fileWrite(fileHandle, "--Got a driving licence by an admin--") 
                fileClose(fileHandle) 
                outputChatBox("You gave the player "..target.." a driving licence.", playerSource, 0, 255, 0 ) 
                outputChatBox("You got a driving licence from "..adminname, targetsource, 0, 255, 0 ) 
            elseif not (fileExists(":wangcars/licences/"..target..".txt")) and (how == 0) then 
                outputChatBox("The player already hasn't got a driving licence.", playerSource, 255, 0, 0 ) 
            end 
    else 
        outputChatBox("It is not confirmed, that you are an admin.", playerSource, 255, 0, 0 ) 
    end 
else 
    outputChatBox("Please enter a number. 1 = yes, 0 = no", playerSource, 255, 0, 0 ) 
end 
end 
addCommandHandler( "setlicence", setLicence ) 
  

I am looking for any kind of help for Resource Scripting in MTA! :D

Posted

Why you still using File functions already fixed your code last time. Here

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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