Phobos
05-14-2009, 03:09 PM
Hello,
im a beginner with lua scripts.
as expected my first command did not gave the desired results.
could someone help me, whats wrong with this code?
The code executes.
but when i type that command ingame, it always shows the "weed" effect, even if i type /drug coke or /drug heroin or /drug
function BuyDrugs(PlayerID,Text)
local drugtype={}
if drugtype==nil then
outputChatBox(PlayerID,"Syntax: /drug <weed or coke or heroin>",255,0,0,255)
elseif isPlayerSpawned(PlayerID) == 0
then
outputChatBox(PlayerID,"Error: You must be spawned.",255,0,0,255)
elseif strval(drugtype)==strval("weed")
then
togglePlayerDrunk (PlayerID,1)
outputChatBox(PlayerID,"You consumed Weed, you are high!",255,0,0,255)
elseif strval(drugtype)==strval("coke")
then
setPlayerGravity(PlayerID,0.8)
outputChatBox(PlayerID,"You consumed Cocain, you are high!",255,0,0,255)
elseif strval(drugtype)==strval("heroin")
then
togglePlayerDrunk (PlayerID,1)
setPlayerGravity(PlayerID,0.8)
outputChatBox(PlayerID,"You consumed Heroin, you are high!",255,0,0,255)
end
end
addCommand("drug","BuyDrugs")
im a beginner with lua scripts.
as expected my first command did not gave the desired results.
could someone help me, whats wrong with this code?
The code executes.
but when i type that command ingame, it always shows the "weed" effect, even if i type /drug coke or /drug heroin or /drug
function BuyDrugs(PlayerID,Text)
local drugtype={}
if drugtype==nil then
outputChatBox(PlayerID,"Syntax: /drug <weed or coke or heroin>",255,0,0,255)
elseif isPlayerSpawned(PlayerID) == 0
then
outputChatBox(PlayerID,"Error: You must be spawned.",255,0,0,255)
elseif strval(drugtype)==strval("weed")
then
togglePlayerDrunk (PlayerID,1)
outputChatBox(PlayerID,"You consumed Weed, you are high!",255,0,0,255)
elseif strval(drugtype)==strval("coke")
then
setPlayerGravity(PlayerID,0.8)
outputChatBox(PlayerID,"You consumed Cocain, you are high!",255,0,0,255)
elseif strval(drugtype)==strval("heroin")
then
togglePlayerDrunk (PlayerID,1)
setPlayerGravity(PlayerID,0.8)
outputChatBox(PlayerID,"You consumed Heroin, you are high!",255,0,0,255)
end
end
addCommand("drug","BuyDrugs")