Page 1 of 2
Making a new command
Posted: Tue May 05, 2015 5:07 pm
by Viper20184
So, I am probably way off here. I saw another thread with how to reset dynamis timer by using the setplayervar command.. but I do not want to make this global but i do want to let people reset their timers. I tried changing the reset timer in the config file and rebuilt the server files but people were telling me their timers were still normal so I would rather make a command to let them reset. I tried to use the setplayervar as a base ... looked through other commands to try and get a feel... but im not sure where I went wrong (probably everywhere). So after reading through code, editing out things i didnt think needed to be in there, this is what I have:
Code: Select all
---------------------------------------------------------------------------------------------------
-- func: dynareset
-- desc: Resets Dynamis timer for user
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 0,
parameters = "ssi"
};
function onTrigger(player)
player:setVar(dynaWaitxDay, 0);
Basically I want the person to be able to use @dynareset and be able to go back in. Any advice? I had an end at the very end.. but both ways it did not work. sometimes it would shoot an error and others it would crash the game server.
Re: Making a new command
Posted: Tue May 05, 2015 6:13 pm
by kjLotus
setVar expects a string as the first parameter (you need quotes to declare a string)
while you're at it, the command itself has no parameters, so parameters in cmdprops should just be ""
Re: Making a new command
Posted: Tue May 05, 2015 7:31 pm
by TeoTwawki
I actually did this awhile back because I got sick of forgetting the exact string for the var name to use with @setplayervar...I was always getting capitalization on that damn "X" wrong.
Code: Select all
---------------------------------------------------------------------------------------------------
-- func: @dynareset <player name>
-- auth: TeoTwawki
-- desc: Resets dynamis wait timer for target player or self
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "s"
};
function onTrigger(player, target)
if (target == nil) then
player:setVar("dynaWaitxDay", 0);
player:PrintToPlayer("Done.");
else
local targ = GetPlayerByName( target );
if (targ ~= nil) then
targ:setVar("dynaWaitxDay", 0);
targ:PrintToPlayer("Your Dynamis Timer has been reset.");
player:PrintToPlayer("Done.");
else
player:PrintToPlayer(string.format("Player named '%s' not found!", target));
end
end
end
As you can see mine was intended mainly to target others.
Re: Making a new command
Posted: Tue May 05, 2015 8:44 pm
by Viper20184
Cool thanks for the info guys. Ill give that a try now
Re: Making a new command
Posted: Thu Jun 25, 2015 8:35 pm
by Desufire
Gonna necro this topic because I need help with making a new command, so this fits lol.
Trying to create a command similar to @return. I need it to reload the player into the current zone they're in though. I'm wanting to use this as a @stuck command for players who get, well, stuck.
So far what I have is a modified @return script though that only targets the player. Everything else I try either crashes my client or returns errors.
Code: Select all
cmdprops =
{
permission = 1,
parameters = "s"
};
function onTrigger(player)
local ZoneID = 0;
player:getName();
ZoneID = player:getPreviousZone();
if (ZoneID == nil or ZoneID == 0) then
player:PrintToPlayer( "Previous Zone was a Mog House or there was a problem fetching the ID.");
else
player:setPos( 0, 0, 0, 0, ZoneID );
end
end
Re: Making a new command
Posted: Fri Jun 26, 2015 2:11 am
by Skrakle
Here's a lua command i made last year, it teleported the player to their previous zone, i just tested it with current build.
Code: Select all
---------------------------------------------------------------------------------------------------
-- func: unstuck
-- auth: Vivitaru
-- desc: Teleports a player to their previous zone
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 0,
parameters = ""
};
function onTrigger(player)
local nextwait=player:getVar("unstuck_wait");
if (os.time(now)>nextwait) then
if (player:getPreviousZone()==player:getZone():getID()) then
player:warp();
else
player:setPos(0,0,0,0,player:getPreviousZone());
player:setVar("unstuck_wait", os.time(now)+3600);
end
else
local mins=math.floor((nextwait-os.time(now))/60)+1;
player:PrintToPlayer("*** You must wait "..mins.." more minutes before unstuck reuse.");
return;
end
end
Re: Making a new command
Posted: Fri Jun 26, 2015 6:53 pm
by Desufire
I didn't think about adding a wait time to the return command. That will work for now but I would really like a command that would just reload the player into the current zone.
Thanks Shrakle.
Re: Making a new command
Posted: Fri Jun 26, 2015 7:06 pm
by kjLotus
Desufire wrote:I didn't think about adding a wait time to the return command. That will work for now but I would really like a command that would just reload the player into the current zone.
Thanks Shrakle.
player:setPos(0,0,0,0,player:getZoneID());
literally that's all you need
Re: Making a new command
Posted: Sat Jun 27, 2015 12:23 am
by Desufire
kjLotus wrote:Desufire wrote:I didn't think about adding a wait time to the return command. That will work for now but I would really like a command that would just reload the player into the current zone.
Thanks Shrakle.
player:setPos(0,0,0,0,player:getZoneID());
literally that's all you need
Seriously? I was making it harder than it needed to be? /sigh
Re: Making a new command
Posted: Sat Jun 27, 2015 1:23 am
by kjLotus
Desufire wrote:kjLotus wrote:Desufire wrote:I didn't think about adding a wait time to the return command. That will work for now but I would really like a command that would just reload the player into the current zone.
Thanks Shrakle.
player:setPos(0,0,0,0,player:getZoneID());
literally that's all you need
Seriously? I was making it harder than it needed to be? /sigh
yep.. common mistake actually, overcomplicating!