• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Addons on Frags

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,901
Reaction score
26
Location
Canada
Well, I was working on a simple script for a War server or something where players gain Addons for the certian total Frags they have.

Add this to your functions.lua
Lua:
function doPlayerAddTfrag(cid, add)
	return db.executeQuery("UPDATE `players` SET `tfrags` = `tfrags` + "..add.." WHERE `name` = '"..getCreatureName(cid).."';")
end

function getPlayerTfrags(cid)
	local DB_points = db.getResult("SELECT `tfrags` FROM `players` WHERE `name` = '"..getCreatureName(cid).."';")
	points = DB_points:getDataInt("tfrags")
	DB_points:free()
	return points
end

Then make this query to your DataBase
PHP:
ALTER TABLE players ADD tfrags varchar(255) NOT NULL

creaturescripts.xml
PHP:
<event type="think" name="FragAddons" event="script" value="FragAddons.lua"/>

login.lua
Lua:
registerCreatureEvent(cid, "FragAddons")

FragAddons.lua
Lua:
function onThink(cid, interval)
	if(getPlayerTfrags(cid) == 5) and (getPlayerStorageValue(cid, 1000) == -1)then
     doPlayerAddOutfitId(cid,1,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 5 Frags total you are rewarded with Full Citizen Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1000,1)  
      else                
		return true
	end
		if(getPlayerTfrags(cid) == 10) and (getPlayerStorageValue(cid, 1001) == -1)then
     doPlayerAddOutfitId(cid,2,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 10 Frags total you are rewarded with Full Hunter Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1001,1)  
      else               
		return true
	end
		if(getPlayerTfrags(cid) == 20) and (getPlayerStorageValue(cid, 1002) == -1)then
     doPlayerAddOutfitId(cid,3,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 20 Frags total you are rewarded with Full Mage Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1002,1)
      else                 
		return true
	end
	  	if(getPlayerTfrags(cid) == 35) and (getPlayerStorageValue(cid, 1003) == -1)then
     doPlayerAddOutfitId(cid,4,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 35 Frags total you are rewarded with Full Knight Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1003,1) 
      else                  
		return true
	end
	   if(getPlayerTfrags(cid) == 50) and (getPlayerStorageValue(cid, 1004) == -1)then
     doPlayerAddOutfitId(cid,5,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 35 Frags total you are rewarded with Full Noble Outfit Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1004,1) 
      else                  
		return true
	end
       if(getPlayerTfrags(cid) == 75) and (getPlayerStorageValue(cid, 1005) == -1)then
     doPlayerAddOutfitId(cid,6,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 75 Frags total you are rewarded with Full Summoner Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1005,1)
     else    
		return true
	end
	   if(getPlayerTfrags(cid) == 100) and (getPlayerStorageValue(cid, 1006) == -1)then
     doPlayerAddOutfitId(cid,7,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 100 Frags total you are rewarded with Full Warrior Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1006,1) 
      else  
		return TRUE
	end
	   if(getPlayerTfrags(cid) == 125) and (getPlayerStorageValue(cid, 1007) == -1)then
     doPlayerAddOutfitId(cid,8,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 125 Frags total you are rewarded with Full Barbarian Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1007,1) 
      else  
		return TRUE
	end 
        if(getPlayerTfrags(cid) == 150) and (getPlayerStorageValue(cid, 1008) == -1)then
     doPlayerAddOutfitId(cid,9,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 150 Frags total you are rewarded with Full Druid Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1008,1)
      else   
		return TRUE
	end   
      if(getPlayerTfrags(cid) == 175) and (getPlayerStorageValue(cid, 1009) == -1)then
     doPlayerAddOutfitId(cid,10,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 175 Frags total you are rewarded with Full Wizard Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1009,1) 
      else  
		return TRUE
	end   
      if(getPlayerTfrags(cid) == 225) and (getPlayerStorageValue(cid, 1010) == -1)then
     doPlayerAddOutfitId(cid,11,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 225 Frags total you are rewarded with Full Oriental Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1010,1) 
      else  
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 275) and (getPlayerStorageValue(cid, 1011) == -1)then
     doPlayerAddOutfitId(cid,12,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 275 Frags total you are rewarded with Full Pirate Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1011,1) 
      else  
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 325) and (getPlayerStorageValue(cid, 1012) == -1)then
     doPlayerAddOutfitId(cid,13,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 325 Frags total you are rewarded with Full Assassin Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1012,1)
      else   
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 375) and (getPlayerStorageValue(cid, 1013) == -1)then
     doPlayerAddOutfitId(cid,14,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 375 Frags total you are rewarded with Full Beggar Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1013,1)
      else   
		return TRUE
	end
	 if(getPlayerTfrags(cid) == 450) and (getPlayerStorageValue(cid, 1014) == -1)then
     doPlayerAddOutfitId(cid,15,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 450 Frags total you are rewarded with Full Shaman Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1014,1) 
       else 
		return TRUE
	end
	 if(getPlayerTfrags(cid) == 525) and (getPlayerStorageValue(cid, 1015) == -1)then
     doPlayerAddOutfitId(cid,16,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 525 Frags total you are rewarded with Full Norsemen Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1015,1) 
      else  
		return TRUE
	end
	 if(getPlayerTfrags(cid) == 600) and (getPlayerStorageValue(cid, 1016) == -1)then
     doPlayerAddOutfitId(cid,17,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 600 Frags total you are rewarded with Full Nightmare Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1016,1)
      else   
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 700) and (getPlayerStorageValue(cid, 1017) == -1)then
     doPlayerAddOutfitId(cid,18,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 700 Frags total you are rewarded with Full Jester Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1017,1) 
      else  
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 800) and (getPlayerStorageValue(cid, 1018) == -1)then
     doPlayerAddOutfitId(cid,19,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 800 Frags total you are rewarded with Full Brotherhood Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1018,1) 
       else 
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 900) and (getPlayerStorageValue(cid, 1019) == -1)then
     doPlayerAddOutfitId(cid,20,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 900 Frags total you are rewarded with Full Demonhunter Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1019,1) 
      else  
		return TRUE
	end
	  if(getPlayerTfrags(cid) == 1000) and (getPlayerStorageValue(cid, 1020) == -1)then
     doPlayerAddOutfitId(cid,21,3)
       doPlayerSendTextMessage(cid,21,"For obtaining 1000 Frags total you are rewarded with Full Yalaharian Addons!")
       doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        setPlayerStorageValue(cid,1020,1)        	
       else
      end 
       return TRUE      
    end

And to make it so the players get a Tfrag onkill add this to a Kill script:
Lua:
doPlayerAddTfrag(cid, 1)

Explanation: After a player receives 5 Total Frags they will receive Full Citizen Addons and once they receive 10 Total Frags they will receive full hunter addon. And so on~
 
As I can change so that these are temporary?
So as to get the addons and lose at death.
 
ahm yes i guess .. its updateable
i think its morre advisable to use onKill
 
[03/07/2010 04:33:45] [Warning - Event::loadScript] Event onKill not found (data/creaturescripts/scripts/FragAddons.lua)
 
i did not mean that man :p well i'll give it a try
 
let's see 30m, doing it fine, no sql needed at all
final output will be like:

Lua:
local t = {
    baseSt = 1000, --storages from 1000 to 1021 will be used 
    frags = 999, --storage to store the amount of frags of the player
    }

    frags = function(cid) --frags, storage, outfitID, name
    local s = {
        {1000,t.baseSt+20,21,'Yalaharian'},
        {900,t.baseSt+19,20,'Demonhunter'},
        {800,t.baseSt+18,19,'Brotherhood'},
        {700,t.baseSt+17,18,'Jester'},
        {600,t.baseSt+16,17,'Nightmare'},
        {525,t.baseSt+15,16,'Norsemen'},
        {450,t.baseSt+14,15,'Shaman'},
        {375,t.baseSt+13,14,'Beggar'},
        {325,t.baseSt+12,13,'Assassin'},
        {275,t.baseSt+11,12,'Pirate'},
        {225,t.baseSt+10,11,'Oriental'},
        {175,t.baseSt+9,10,'Wizard'},
        {150,t.baseSt+8,9,'Druid'},
        {125,t.baseSt+7,8,'Barbarian'},
        {100,t.baseSt+6,7,'Warrior'},
        {75,t.baseSt+5,6,'Summoner'},
        {50,t.baseSt+4,5,'Noble'},
        {35,t.baseSt+3,4,'Knight'},
        {20,t.baseSt+2,3,'Mage'},
        {10,t.baseSt+1,2,'Hunter'},
        {5,t.baseSt,1,'Citizen'},
    }
        for _, t in ipairs(s) do
            if getCreatureStorage(cid,t.frags) >= t[1] then
                return t
            end
        end
    end

function onKill(cid, target, deathlist
    if not isPlayer(cid) and not isPlayer(target) then
        return true
    end
    
    local frags = getCreatureStorage(cid,t.frags)
    doCreatureSetStorage(cid,t.frags,frags+1)

    if getCreatureStorage(cid, frags(cid)[2]) == -1 then
        doPlayerAddOutfitId(cid,frags(cid)[3],3)
        doPlayerSendTextMessage(cid,21,'For obtaining '.. frags ..' Frags total you are rewarded with full '.. frags(cid)[4] ..' outfit addons!')
        doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))        
        doCreatureSetStorage(cid,frags(cid)[2],1)  
    end
return true
end
 
it works exactly like the main script, this one is shortened and does not use sql queries(less lag for ot, just a bit)
 
Back
Top