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

setPlayerGroupId not working

muphet

New Member
Joined
Apr 27, 2008
Messages
233
Reaction score
2
Hi. I have a script which changing player's group, but it working only one time..

Code:
function onCastSpell(cid, var)
	if getPlayerVocation(cid) == X then     
		if getPlayerGroupId(cid) == 1 then     
			setPlayerGroupId(cid,2)   			
		end 
	else
		doPlayerSendCancel(cid, "Sorry, you cannot use this ability.")
	end 
end
That one working. When player is in group 2 and he use spell of this code:
Code:
function onCastSpell(cid, var)
	if getPlayerVocation(cid) == X then     
		if getPlayerGroupId(cid) == 2 then     
			setPlayerGroupId(cid,1)   			
		end 
	else
		doPlayerSendCancel(cid, "Sorry, you cannot use this ability.")
	end 
end
server do nothing.. What I need to do?
And, how to add an effects to this spell? When I add effects like
CONST_ME_MAGIC_RED, nothing appear..

this function changing group id, and 2nd group have own flags.
Help!
 
use talkactions

HTML:
function onSay(cid, words, param)

	vocations = {3, 4, 7, 8, 11, 12} -- only vocations that can use this command
	
	if(isInArray(vocations, getPlayerVocation(cid))) then
		if(getPlayerGroupId(cid) < 2) then
			doPlayerSetGroupId(cid, 2)
			doSendMagicEffect(getCreaturePosition(cid), 12)
		elseif(getPlayerGroupId(cid) == 2) then
			doPlayerSetGroupId(cid, 1)
			doSendMagicEffect(getCreaturePosition(cid), 2)
		else
			doPlayerSendCancel(cid, "Sorry, you cannot use this ability.")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you cannot use this ability.")
	end
	return true
end

HTML:
<talkaction words="!upgroup" script="upgroup.lua"/>
 
Code:
function onSay(cid, words, param)
	local v = {3, 4} --only vocationIds that can use this command
	if not isInArray(vocations, getPlayerVocation(cid)) then
		return getPlayerGroupId == 1 and doPlayerSetGroupId(cid, 2) or doPlayerSetGroupId(cid, 1)
	else
		doPlayerSendCancel(cid, "Sorry, you can't use this ability.")
	end
	return true
end
 
Code:
function onSay(cid, words, param)
	local v = {3, 4} --only vocationIds that can use this command
	if not isInArray(vocations, getPlayerVocation(cid)) then
		return getPlayerGroupId == 1 and doPlayerSetGroupId(cid, 2) or doPlayerSetGroupId(cid, 1)
	else
		doPlayerSendCancel(cid, "Sorry, you can't use this ability.")
	end
	return true
end
Code:
function onSay(cid, words, param, channel)
	return isInArray({3, 4}, getPlayerVocation(cid)) and getPlayerGroupId(cid) == 1 and doPlayerSetGroupId(cid, 2) or doPlayerSetGroupId(cid, 1) or doPlayerSendCancel(cid, "Sorry, you can't use this ability.")
end
not sure about the last part ;d
 
Thank you kkk111. Now it's working, but I have 2 problems.
First: How to add exhaustion in talkactions?
After player use this command and get downgraded to 1 group (from 2), he get exhaustion for period of time.
Second: The second group has other flags than first. I mean, it have "invisible flag". Can I add function, that will change outift to another (with addons) and after downgrade change to outfit that player have before this action? /huh, sorry for eng :p
 
Back
Top