Community Resources: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 52: Line 52:
'''Returns:''' a table of usernames in the group
'''Returns:''' a table of usernames in the group


==Examples==
<section name="Group Example" class="server" show="true">
This outputs the servers group name, if the group is public or private, and the registration time.
<syntaxhighlight lang="lua">
addEventHandler("onPlayerJoin",getRootElement(),function()
  callRemote("http://community.mtasa.com/mta/groups.php",info,"info",1) --When the player joins, call the site for the info
end)
function info(groupName,ownerUser,members,public,registrationTime) --Define all the values
  if(groupName)and(public)and(registrationTime)then --check if the info came through
      outputChatBox("Our group is in the MTA Community Site, it's called: "..groupName..", our groups is "..public.." and was registered in"..registrationTime..".",source,0,100,100) --output about the servers new/existing group
  end
end
</syntaxhighlight>
</section>
<section name="Members Example" class="server" show="true">
This outputs the members in the servers group, which is found on the MTA Community Site.
<syntaxhighlight lang="lua">
addCommandHandler("members",function(player)
  callRemote("http://community.mtasa.com/mta/groups.php",function(members,player)--Call after the command goes through
  if(members)then
      outputChatBox("Members in this servers group: "..members..".",player,255,255,255) --Outputs the members to the player who typed in the command
  end
end,"members",1)
end)
</syntaxhighlight>
</section>


==community.mtasa.com/mta/resources.php==
==community.mtasa.com/mta/resources.php==

Revision as of 23:49, 5 April 2012

Community calls documentation

only use:

callRemote()

community.mtasa.com/mta/verify.php

Calls:

User validation:

player thePlayer, string Username, string Serial

Returns: an integer, 1 if user is valid, 0 otherwise

Example

addEventHandler ( "onPlayerJoin", getRootElement(), function()
  local username = getPlayerUserName ( source )
  local serial = getPlayerSerial ( source )
  callRemote ( "http://community.mtasa.com/mta/verify.php", validatePlayer, source, username, serial )
end )

function validatePlayer ( player, result )
  local valid = "invalid"
  if ( result == 1 ) then valid = "valid" end
  outputChatBox ( getPlayerName ( player ).."'s username is "..valid )
end

community.mtasa.com/mta/groups.php

Calls:

Info:

string "info", int groupID

Returns 5 values:
1. Group name
2. Owner username
3. Number of members
4. Public. Integer: 1 if the group is public, 0 otherwise
5. Registration time


Members list:

string "members", int groupID

Returns: a table of usernames in the group

Examples

Click to collapse [-]
Group Example

This outputs the servers group name, if the group is public or private, and the registration time.

addEventHandler("onPlayerJoin",getRootElement(),function()
   callRemote("http://community.mtasa.com/mta/groups.php",info,"info",1) --When the player joins, call the site for the info
end)

function info(groupName,ownerUser,members,public,registrationTime) --Define all the values
   if(groupName)and(public)and(registrationTime)then --check if the info came through
      outputChatBox("Our group is in the MTA Community Site, it's called: "..groupName..", our groups is "..public.." and was registered in"..registrationTime..".",source,0,100,100) --output about the servers new/existing group
   end
end
Click to collapse [-]
Members Example

This outputs the members in the servers group, which is found on the MTA Community Site.

addCommandHandler("members",function(player)
   callRemote("http://community.mtasa.com/mta/groups.php",function(members,player)--Call after the command goes through
   if(members)then
      outputChatBox("Members in this servers group: "..members..".",player,255,255,255) --Outputs the members to the player who typed in the command
   end
end,"members",1)
end)

community.mtasa.com/mta/resources.php

Calls:

Latest resource version:

string "version", string resourceName

Returns: a string, resource version in format of "x.x.x". Integer 0 if an error has occured