Nothing work it ! He was unlogged
And one ask
I have this
--Vars
--Author TwiX [[Don't Remove This Line]]
local price = 500;
addEventHandler ( 'onGamemodeMapStart', root,
function ( mapres )
local txMapName = getResourceName ( mapres );
pHasBought = false;
allGotVehicle = false;
getAliveGuys ( 3 );
saveSqlPlayed ( txMapName );
end
)
function rStart ( )
pHasBought = false;
allGotVehicle = false;
executeSQLQuery ( "CREATE TABLE IF NOT EXISTS tx_MapShop ( mapName TEXT, played INTEGER )" );
getAllMapsFromManager ( );
txBMaps = { }
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), rStart )
function buyNextMap ( player, mapName )
if not player or not mapName then return end
if ( isGuestAccount ( getPlayerAccount ( player ) ) == false ) then
if pHasBought == false then
local money = tonumber ( getPlayerMoney ( player ) );
local theTime = getMsFromMin ( 10 );
if money >= tonumber ( price ) then
if ( not txBMaps [ mapName ] ) then
txBMaps [ mapName ] = true
executeCommandHandler ( "bm", player, mapName ); --This function need admin rights
pHasBought = player;
setTimer ( removeMapFromList, theTime.ms, 1, mapName );
else
outputChatBox ( "* #ff0000'#ffffff" .. mapName .. "#ff0000' #ffffffwill be #abcdefavailable #ffffffin #abcdef10 #ffffffminutes", player, 255, 255, 255, true );
end
else
outputChatBox ( "* You #abcdefdon't #ffffffhave enough #abcdefmoney #ffffffto buy the map!", player, 255, 255, 255, true );
end
else
outputChatBox ( "* A #abcdefmap #ffffffis already bought at the moment! Please #abcdeftry #ffffffagain later", player, 255, 255, 255, true );
end
else
outputChatBox ( "* You should be #abcdeflogged in to buy the map!", player, 255, 255, 255, true );
end
end
addEvent ( "doBuyMap", true )
addEventHandler ( "doBuyMap", root, buyNextMap )
function removeMapFromList ( mapName )
outputChatBox ( "* #abcdef" .. mapName .. " #ffffff - #ffffffis now #abcdefavailable #ffffffat the #abcdefMap Shop!", root, 255, 255, 255, true );
txBMaps [ mapName ] = nil;
end
addEvent ( "onRaceStateChanging", true )
addEventHandler ( "onRaceStateChanging", root,
function ( newState )
if ( newState == "Running" ) then
for k,v in pairs ( getElementsByType ( "player" ) ) do
local hisVehicle = getPedOccupiedVehicle ( v );
if not hisVehicle then return end
setElementData (v, "gotMoney", false );
if isPedInVehicle ( v ) then
allGotVehicle = true;
end
end
if allGotVehicle then
getAliveGuys ( 1 );
end
end
end
)
addEventHandler ( "onPlayerJoin", root,
function ( )
setElementData ( source, "gotMoney", false );
--Atm only setElementData
end
)
--Functions by Admin Panel (lil_Toady)
function getAllMaps ( loadList, s )
local tableOut
if loadList then
tableOut = { };
local gamemodes = { };
gamemodes = call ( getResourceFromName ( "mapmanager" ), "getGamemodes" );
for id, gamemode in ipairs ( gamemodes ) do
tableOut [ id ] = { };
tableOut [ id ].name = getResourceInfo(gamemode,"name") or getResourceName(gamemode);
tableOut [ id ].resname = getResourceName(gamemode);
tableOut [ id ].maps = {};
local maps = call ( getResourceFromName ( "mapmanager" ), "getMapsCompatibleWithGamemode", gamemode );
for _, map in ipairs ( maps ) do
table.insert ( tableOut [ id ][ "maps" ],{ name = getResourceInfo ( map, "name" ) or getResourceName ( map ),resname = getResourceName ( map ) } );
end
table.sort ( tableOut [ id ][ "maps" ],sortCompareFunction );
end
table.sort ( ( tableOut ), sortCompareFunction );
table.insert ( tableOut, { name = "no gamemode", resname = "no gamemode", maps = { } } );
local countGmodes = #tableOut;
local maps = call ( getResourceFromName ( "mapmanager" ), "getMapsCompatibleWithGamemode" );
for id, map in ipairs ( maps ) do
table.insert ( tableOut [ countGmodes ][ "maps" ],{ name = getResourceInfo ( map, "name" ) or getResourceName ( map ), resname = getResourceName (map ) } );
end
table.sort ( tableOut [ countGmodes ][ "maps" ], sortCompareFunction );
end
local map = call ( getResourceFromName ( "mapmanager" ), "getRunningGamemodeMap" );
local gamemode = call ( getResourceFromName ( "mapmanager" ), "getRunningGamemode" );
gamemode = gamemode and getResourceName ( gamemode ) or "N/A";
map = map and getResourceName ( map ) or "N/A";
triggerClientEvent ( "refreshCompleted", loadList, tableOut, gamemode, map, s );
end
addEvent ( "doRefreshMapList", true )
addEventHandler ( "doRefreshMapList", root, getAllMaps )
function sortCompareFunction ( s1, s2 )
if type ( s1 ) == "table" and type ( s2 ) == "table" then
s1, s2 = s1.name, s2.name;
end
s1, s2 = s1:lower ( ), s2:lower( );
if s1 == s2 then
return false
end
local byte1, byte2 = string.byte ( s1:sub ( 1, 1 ) ), string.byte ( s2:sub ( 1, 1 ) );
if not byte1 then
return true
elseif not byte2 then
return false
elseif byte1 < byte2 then
return true
elseif byte1 == byte2 then
return sortCompareFunction ( s1:sub ( 2 ), s2:sub ( 2 ) );
else
return false
end
end
function getAliveGuys ( mode )
if not mode then return end
if mode == 1 then
pAlive = { };
for _, player in ipairs ( getElementsByType ( "player" ) ) do
if ( getElementData ( player, "state" ) == "alive" ) then
table.insert ( pAlive, player );
end
end
return pAlive;
elseif mode == 2 then
return #pAlive;
elseif mode == 3 then
if pAlive then
pAlive = nil;
end
return false
end
end
function getDeadGuys ( )
local pDead = 0
for _, player in ipairs ( getElementsByType ( "player" ) ) do
if getElementData ( player, "state" ) == "dead" then
pDead = pDead + 1;
end
end
return pDead;
end
function giveMoneyWinDie ( )
local account = getPlayerAccount ( source );
local playersAlive = getAliveGuys ( 2 );
local playersDead = getDeadGuys ( );
local pAll = playersAlive + playersDead;
local checkYourPos = pAll - playersDead;
local pos = nil;
if tonumber ( checkYourPos ) == 1 then pos = 1 else pos = checkYourPos + 1; end
if tonumber ( checkYourPos ) == 2 then pos = 2; end
if pos == 1 or pos == 21 or pos == 31 then
posName = "st";
elseif pos == 2 or pos == 22 or pos == 32 then
posName = "nd";
elseif pos == 3 or pos == 23 or pos == 33 then
posName = "rd";
else
posName = "th";
end
if not getElementData ( source, "gotMoney" ) then
local money = math.ceil ( getPlayerCount ( ) * 50 / pos );
givePlayerMoney ( source, money );
outputChatBox ( "* You were #abcdef[#ff0000" .. pos .. posName .. "#abcdef]#ffffff and #abcdefearned #ffffff" .. money .. "#00ff00$!", source, 255, 255, 255, true );
setElementData ( source, "gotMoney", true );
if account then
setAccountData ( account, "money", tostring ( getPlayerMoney ( source ) ) );
end
end
end
addEventHandler ( "onPlayerWasted", root , giveMoneyWinDie )
I need it only on command /dshop not bind