• 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!

Get player position spell script

Albanon

New Member
Joined
Mar 5, 2011
Messages
93
Reaction score
1
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)


function onCastSpell(cid, var)
if isPlayer(cid) == TRUE then
if exhaustion.check(cid, 30030) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your target is: " .. getCreaturePos(var))
return true

end
end
return doCombat(cid, combat, var)
end

I just want the player to cast a spell and get a player position

exiva res "person
then it should return the result
This loads, but it doesn't do anything.

im using this https://otland.net/threads/8-60-the-forgotten-server-0-3-6-crying-damson-v8.147913/
 
You can use a talkaction script.
Code:
local tid = getPlayerByNameWildcard(param)
local pos = getThingPosition(tid)
 
is there any other way to do it with a spell? I'd like it to be a class specific thing. It's not so much that I'm trying to find a player, as I am trying to learn how to do some of the effects I want through scripting, but I appreciate your time and your response, and It is still very useful!
 
Most things you add to spells can also be done in a talkaction. Talkactions have a parameter for param so you can get the position based on player name.
Spell scripts have cid and var, so you can't really do something with a player name, unless you get the target of the player.
 
My over all goal is to create a spell that

gets the target player's position, if he isn't in a protection zone, and he isn't dead, then you can summon 4 "creature name" to his position. The creatures will attack him, but they aren't your summons, so if you happen to be in the area, after they kill him, they'll go after you too. If he ends up dying, id like his body to be teleported back to the player who cast the spell. Is all that possible through talk actions?

thanks again for the reply!
 
It depens how you want to get the position of the target, if it's with target name as param, use a talkaction, if the target is targeted or hit by the spell combat, it's more easy to use a spell.
You can create those 4 monsters with doCreateMonster so it will be wild monsters and use doChallengeCreature to make the monsters target the player target.
 
im going to try to write a talk action for it in a little bit, would you mind looking over it and advising me on my mistakes?



function onSay(cid, words, param, channel)
local tid = getPlayerByNameWildcard(param)
local pos = getThingPosition(tid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (tid))
end

utevo res mort "player name

does nothing :(


actually it returns some long number, but I had to change the say command from "utevo res mort" to utevoresmort apparently it doesn't like spaces



edit again:


ok, so here's my script now. I found some similiar scripts and disected them, but what I'm not understanding is why the get player vocation doesn't seem to work. I must not be writing the code incorrectly, when I take it out, everything else works fine.

before I continue, is there a way to write this code shorter?

I need to make sure the only people who can do this are vocations 9 and 10




Code:
function onSay(cid, words, param, channel)
    local pid = cid
    if getPlayerVocation(cid) ~= 9 ) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "you are the wrong vocation.")
    return true
    end
  
    if (param == '')
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "you must target someone for the spell to work.")
    return true
    end
  
  
    if(param ~= '' and isPlayerGhost(pid)) then
        pid = getPlayerByNameWildcard(param)
        local position = getCreaturePosition(pid)
        doCreateMonster("Dragon", position )
        if(not pid or (isPlayerGhost(pid))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " is not currently online.")
            return true
        end
    end

  
  
  
    return true
end
 
Last edited:
Back
Top