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

Lua TFS 1.0 - PVP ON and OFF not working.

Anghelos

Member
Joined
Nov 1, 2014
Messages
30
Reaction score
10
Hi all :)
My problem of today is about switching from pvp on and off inside the server, in order to have players that do pvp and players that just want to do pve.
The script that I wanted to use is the following:
http://otland.net/threads/pvp-own-world-type.31889/#post-322373

I don't know if it's a TFS 1.0 script (i guess so) but when i try to apply it on my server i have the following error:

[Error - CreatureEvent::configureEvent] Invalid type for creature event: PvpMode
[Warning - BaseEvents::loadfromXml] Failed to configure event

and i just followed the installation...so according with my intuition, is like the 'onCombat' is not take into account.... I tried to make some changes but still nothing changed...so i'm here now to ask help :) Prolly is something stupid that i don't know :)
(ps: yes i already made the SQL query to update the player table)
 
There is no creature event named 'combat' in 1.0
However, if I understand what the creature event 'combat' is intended to do, it should work the same as onTargetCombat (for targeting, onAreaCombat for area damages) in Events.
So, all you need to do is check if to see if self creature (isPlayer) has PVP mode on (through storages, perhaps), and check to see if target creature has PVP mode on as well. If condition passes, then return onTargetCombat as true, else false. In the talkactions for !pvp, all you need to do is check if the self player has PZ lock, if not, then switch PVP mode, else don't switch PVP mode.
 
Last edited:
First, thx for answering :)
Second, I hope u will be patient enough, coz i'm still very noob in this kind of scripting and I still need to figure out a lot of stuff.....for instance thx for giving me the list of 'triggers' (mhm event is more correct i guess) i tried to search for them, didn't know I had to search in the source.

Now, what you ask me to do seems clear, but difficult to me to put in practice.... so first i should add a storage:
Code:
    PvpStatus = {
        Status = 51320
    },
then remake the functions without db but using storages:

Code:
function getPlayerPVPMode(uid)
    local Player = Player(uid)
    if player:getStorageValue(Storage.PvpStatus.Status) == 1 then
        local mode = 1
        return mode
    else
        return FALSE
    end
end

function setPlayerPVPMode(uid, value)
    if (value >= 0 and value <= 1) then
        if isPlayer(uid) == TRUE then
            player:setStorageValue(Storage.PvpStatus.Status, value)
            return TRUE
        else
            return FALSE
        end
    else
        return FALSE
    end
end
Hope i didn't write bullshit 'till now (but prolly i did).

here i just change creatureskulltype with playerskulltype

Code:
function onSay(cid, words, param)
    local mode = getPlayerPVPMode(cid)
    local player = Player(cid)
    if mode == 1 then
        setMode = 0
    else
        setMode = 1
    end
    if isPlayerPzLocked(cid) == FALSE and getPlayerSkullType(cid) == SKULL_NONE then
        setPlayerPVPMode(cid, setMode)
        if setMode == 1 then
            doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to on!")
        else
            doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to off!")
        end
    else
        doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.")
    end
    return TRUE
end

now problem is here:

the function for the aoe and targets, I found that the functions OnTargetCombat and OnAreaCombat are 'creature' functions, so i added:

Code:
<!-- Creature methods -->

    <event class="Creatures" method="OnAreaCombat" enabled="1"/>
    <event class="Creatures" method="OnTargetCombat" enabled="1"/>
and i created inside scripts, a file called creatures.lua with inside:

Code:
function onTargetCombat(cid, target)
    if (getPlayerPVPMode(cid) == 1 and getPlayerPVPMode(target) == 1) or isPlayer(target) == FALSE then
        return TRUE
    else
        doPlayerSendCancel(cid, "You cannot attack players which pvp mode is off.")
        return FALSE
    end
end
The server crashes ;_;

while if i put "Creature" (without final s) I receive the error: Unknow class Creature...
i'm getting crazy :(

if u have hints, I'm more than welcome to hear :)
 
Last edited:
Back
Top