[PM] Function release.

Share your gamemodes and snippets here
Post Reply
#Dav
Posts: 2
Joined: Sun Jun 02, 2019 2:42 am
Location: Greece

[PM] Function release.

Post by #Dav » Sat Jun 22, 2019 12:05 pm

Hello everyone, as I'm done with IV:MP I will start sharing some of the semi-finished scripts I made.

You are free to rework them and reshare those scripts, it need to be tested but I have no time for this,
feel free to fix any issues you may notice.

Code: Select all

function pmToPlayer(playerid, text)
	local cmd = string.find(text, "/pm")
	if (cmd ~= nil) then
		local details = split(text, " ")
		if (#details < 3) then
			sendPlayerMsg(playerid, "Usage: /pm [ID] [text]", 0xFFFE6776)
			return
		end
		if (type(tonumber(details[2])) ~= "number") then
			sendPlayerMsg(playerid, "Player id must be a number.", 0xFFFE6776)
			return
		end
		if (not isPlayerOnline(tonumber(details[2]))) then
			sendPlayerMsg(playerid, "Player is offline.", 0xFFFE6776)
			return
		end
		if (logged_players[playerid] == nil) then
			sendPlayerMsg(playerid, "You are not logged in.", 0xFFFE6776)
			return
		end
		
		local id_len = string.len(details[2])
		local msg = string.sub(text, (id_len+6))
		
		sendPlayerMsg(playerid, "PM to "..getPlayerName(playerid).."("..playerid.."): "..msg, 0xFFFFFF00)
		sendPlayerMsg(tonumber(details[2]), "PM from "..getPlayerName(playerid).."("..playerid.."): "..msg, 0xFFFFFF00)
	end
end
registerEvent("pmToPlayer", "onPlayerCommand")
"Many humans do not care about what is "unfair,"
for it varies so much between them."

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest