• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

So my script work?

Mithaz

Nightimp Mapper/Scripter
Joined
Nov 7, 2007
Messages
120
Reaction score
1
Location
Sweden
Hello. Doing some scripting in the school and dont have things to test it.
Im new to lua and this is my first time trying to make a script.

This script shold add the storage value to the player.
Was going to use this to make the outfits Vocation based.

So a a noob lua scripter like me want to know if my script works or not.
And all tips and hints how i shall improve my scripting and what i shold think of is welcomed :thumbup:

Here is the script
Code:
-- Zarbon made this script
-- Date :: 2010-11-18 :: 13.00
-- Location :: Sweden

--The storage ID's
StorMage = 1500;
StorDruid = 2600;
StorPaladin = 3700;
StorKnight = 4800;


--Check Vocation and set the storage!
if ( isSorcerer )
{	
	
	setPlayerStorageValue(cid, StorMage, 1)

}
elseif ( isDruid )
{

	setPlayerStorageValue(cid, StorDruid, 1)

}
elseif ( isPaladin )
{
	
	setPlayerStorageValue(cid, StorPaladin, 1)

}
elseif ( isKnight )
{

	setPlayerStorageValue(cid, StorKnight, 1)

}
 
Lua:
-- Zarbon made this script
-- Date :: 2010-11-18 :: 13.00
-- Location :: Sweden

--The storage ID's
local StorMage = 1500;
local StorDruid = 2600;
local StorPaladin = 3700;
local StorKnight = 4800;

local player = getPlayerVocationName(cid)


--Check Vocation and set the storage!
if player == 1 then
	setPlayerStorageValue(cid, StorMage, 1)
elseif player == 2 then
	setPlayerStorageValue(cid, StorDruid, 1)
elseif player == 3 then	
	setPlayerStorageValue(cid, StorPaladin, 1)
elseif player == 4 then
	setPlayerStorageValue(cid, StorKnight, 1)
return true
end

though what are you gonna use it with, a action or movement or?
 
Think it shold be a creaturescript.
Was thinking to use it when the player login he gets the storage value and then he can only choose the outfits that has that value.
So then i shold use this as a creaturescript if im not totaly wrong :D
 
Mithaz your code it is based on PHP programming, and yes it is a creaturescript:
Lua:
function onLogin(cid)
-- Zarbon made this script
-- Date :: 2010-11-18 :: 13.00
-- Location :: Sweden
 
--The storage ID's
local StorMage = 1500
local StorDruid = 2600
local StorPaladin = 3700
local StorKnight = 4800
local player = getPlayerVocation(cid)
 
 
--Check Vocation and set the storage!
if player == 1 then
	setPlayerStorageValue(cid, StorMage, 1)
elseif player == 2 then
	setPlayerStorageValue(cid, StorDruid, 1)
elseif player == 3 then	
	setPlayerStorageValue(cid, StorPaladin, 1)
elseif player == 4 then
	setPlayerStorageValue(cid, StorKnight, 1)
return true
end

Creaturescript.xml
XML:
<event type="login" name="loginregister" script="name.lua"/>
 
mind using tables?
Lua:
-- Zarbon made this script
-- Date :: 2010-11-18 :: 13.00
-- Location :: Sweden

--The storage ID's
local table = {
    [1] = 1500, --mage
    [2] = 2600, --druid
    [3] = 3700, --paladin
    [4] = 4800 --knight
}
    
function onLogin(cid)     
    --Check Vocation and set the storage!
    if table[getPlayerVocation(cid)] then
        setPlayerStorageValue(cid, table[getPlayerVocation(cid)], 1)
    end
    return true
end
 
Lua:
function onLogin(cid)
	local v = getPlayerVocation(cid)
	return true, v > 0 and v < 5 and setPlayerStorageValue(cid, v * 1000 + 400 + v * 100, 1)
end
 
Back
Top Bottom