Jump to content

[HELP] Commands


joaosilva099

Recommended Posts

Posted

Hi all i have commands in my server that should have an arg that is a player nickname

My problem is that i have to type the nickname exactly same the player's nickname.

I saw other servers that you just type (example) "t/loc Joao" and the script gets my full name that is (example) "|SS|Joao|F"

I searched the wiki already but how can i get the player's nick with approximated name?

350x20_FFFFFF_FFFFFF_000000_000000.png

http://i.imgur.com/CSE28MJ.png

Don't hesitate to contact me for anything! If I can help, I will for sure!

Education is the most powerful weapon which you can use to change the world. - Castillo

Posted

i understand u use this function

  
function findPlayer(player) 
       if player and type(player) == "string" then 
                local plr = getPlayerFromName 
                if plr then return plr end 
                 local pC = 0 
                 local player = string.lower(player) 
                 local spl = split(player, string.byte("[")) 
                   if spl then 
                            player = table.contact(spl, ";") 
                     end 
                      for k, v in ipairs(getElementsByType("player") do 
                           local nam = string.lower(getPlayerName(v) 
                          local spl = split(nam, string.byte("[")) 
                         if spl then 
                                   nam = table.contact(spl, ";") 
                         end 
if string.find(name, player) then plr = v pC = pC  + 1 
end 
end 
if plr and pC == 1 then 
return plr 
end 
return false 
else return false 
end 
end  
  
  
  
--- copy this function and use it like this 
-- player = findPlayer(partOfPlayerName) 
   
  

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

I think you helped me!! I cant test now in my mobile but tomorow i test on pc. This will return the player element right? Or the player's complete name?

350x20_FFFFFF_FFFFFF_000000_000000.png

http://i.imgur.com/CSE28MJ.png

Don't hesitate to contact me for anything! If I can help, I will for sure!

Education is the most powerful weapon which you can use to change the world. - Castillo

Posted

It return the player element the code is kinda messy i dont test it (i write it using mobile)

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

Edited some things that were error like "no elements in the function getPlayerFromName" and "table concat instead of table contact

but still not working

  
function findPlayer(player) 
       if (player and type(player) == "string") then 
                local plr = getPlayerFromName(player) 
                if (plr ~= false) then return plr end 
                 local pC = 0 
                 local player = string.lower(player) 
                 local spl = split(player, string.byte("[")) 
                   if spl then 
                            player = table.concat(spl, ";") 
                     end 
                      for k, v in ipairs(getElementsByType("player")) do 
                           local nam = string.lower(getPlayerName(v)) 
                          local spl = split(nam, string.byte("[")) 
                         if spl then 
                                   nam = table.concat(spl, ";") 
                         end 
if string.find(name, player) then plr = v pC = pC  + 1 
end 
end 
if plr and pC == 1 then 
return plr 
end 
return false 
else return false 
end 
end 
  

350x20_FFFFFF_FFFFFF_000000_000000.png

http://i.imgur.com/CSE28MJ.png

Don't hesitate to contact me for anything! If I can help, I will for sure!

Education is the most powerful weapon which you can use to change the world. - Castillo

Posted

try

string.find 

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

good this the bug test it i will wait

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

i have but i use mobile

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

cant using phone i wil add u tommorow using pc

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

Does the code work

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted
function findPlayer ( pName ) 
  
    if not pName then return end -- Make sure we have a name to look for 
  
    local players = {} -- Create a table in case of finding more than 1 player with the matching name 
  
    for k, element in ipairs ( getElementsByType ( "player") ) do -- start looping the players and check the name against their name 
      
        local name = getPlayerName ( element ) -- Get their name 
  
        if string.find ( name, pName ) then -- Check it against the name we are looking for 
            table.insert ( players, element ) -- Save it into our table 
        end 
      
    end 
  
    if #players > 1 then -- If found more than 1, return the whole table with the players matching the name 
        return players 
    elseif #players == 1 then -- If we found only one, return that single element 
        return players [ 1 ] 
    else -- we haven`t found anything, return false 
        return false 
    end 
  
end 

Posted

My code aleardy work for him

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...