Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onSay(cid, words, param)
- t = string.explode(param, ",")
- stor = 31721
- pname = 31722
- max = 3 -- Mรกximo de players na party
- if t[1] == "invite" then
- if not t[2] then
- doPlayerSendCancel(cid, "Incorrect params.") return true
- elseif not isInParty(cid) or getPartyLeader(cid) ~= cid then
- doPlayerSendCancel(cid, "You must be a party leader to use this command.") return true
- elseif not getPlayerByName(t[2]) then
- doPlayerSendCancel(cid, "Player not found.") return true
- elseif #getPartyMembers(cid) >= max then
- doPlayerSendCancel(cid, "Sorry, but your party is at the full capacity ("..max.." players).") return true
- elseif isInParty(getPlayerByName(t[2])) then
- doPlayerSendCancel(cid, "Sorry, but this player is already in a party.") return true
- elseif getPlayerStorageValue(getPlayerByName(t[2]), pname) ~= -1 then
- doPlayerSendCancel(cid, "Sorry, but this player already has an invitation.") return true
- end
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You invited "..t[2].." to your party.")
- doPlayerSendTextMessage(getPlayerByName(t[2]), MESSAGE_STATUS_CONSOLE_BLUE, "You have been invited to a party by "..getCreatureName(cid)..". Use !party accept or reject.")
- setPlayerStorageValue(getPlayerByName(t[2]), stor, 1)
- setPlayerStorageValue(getPlayerByName(t[2]), pname, getCreatureName(cid))
- elseif t[1] == "accept" then
- if t[2] then
- doPlayerSendCancel(cid, "Incorrect params.") return true
- elseif not getPlayerStorageValue(cid, stor) == 1 then
- doPlayerSendCancel(cid, "You haven't any party invitations.") return true
- elseif isInParty(cid) then
- doPlayerSendCancel(cid, "You are already in a party.") return true
- elseif not getPlayerByName(getPlayerStorageValue(cid, pname)) then
- doPlayerSendCancel(cid, "The party leader is offline. Invitation canceled.")
- setPlayerStorageValue(cid, stor, -1)
- setPlayerStorageValue(cid, pname, -1) return true
- end
- setPlayerStorageValue(cid, stor, -1)
- doPlayerSendTextMessage(getPlayerByName(getPlayerStorageValue(cid, pname)), MESSAGE_STATUS_CONSOLE_BLUE, ""..getCreatureName(cid).." has joined your party.")
- doPlayerJoinParty(cid, getPlayerByName(getPlayerStorageValue(cid, pname)))
- setPlayerStorageValue(cid, pname, -1)
- elseif t[1] == "reject" then
- if t[2] then
- doPlayerSendCancel(cid, "Incorrect params.") return true
- elseif not getPlayerStorageValue(cid, stor) == 1 then
- doPlayerSendCancel(cid, "You haven't any party invitations.") return true
- elseif isInParty(cid) then
- doPlayerSendCancel(cid, "You are already in a party.") return true
- elseif not getPlayerByName(getPlayerStorageValue(cid, pname)) then
- doPlayerSendCancel(cid, "The party leader is offline. Invitation canceled.")
- setPlayerStorageValue(cid, stor, -1)
- setPlayerStorageValue(cid, pname, -1) return true
- end
- doPlayerSendTextMessage(getPlayerByName(getPlayerStorageValue(cid, pname)), MESSAGE_STATUS_CONSOLE_BLUE, ""..getCreatureName(cid).." has rejected your party invitation.")
- setPlayerStorageValue(cid, stor, -1)
- setPlayerStorageValue(cid, pname, -1)
- elseif t[1] ~= "invite" or t[1] ~= "accept" or t[1] ~= "reject" then
- return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can only "invite" a player to your party or "accept" or "reject" an invitation.')
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment