EngMohamedLish Posted June 7, 2015 Share Posted June 7, 2015 (edited) Here in this script, there's a problem i don't understand: addCommandHandler ("revive", function(player, cmd, player2) target = getPlayerFromName(player2) if target then if isElementDead(target) then local x, y, z = getElementPosition(target) spawnPlayer(target, x, y, z) outputChatBox ("You've Revived"..target, player, 0, 255, 0, false) outputChatBox (getPlayerFromName(player).."revived you", target, 0, 255, 0, false) else outputChatBox("syntax: /revive player name", player) end end end) I made this script to revive dead people i get this error: Bad Argument @ 'getPlayerFromName [Expected string at argument 1, got nil] How it's nil? I don't understand, how can i make it so... Edited June 7, 2015 by Guest Link to comment
Walid Posted June 7, 2015 Share Posted June 7, 2015 Try this it should work addCommandHandler ("revive", function(player, cmd, player2) local target = getPlayerFromPartialName(player2) if target then if isPedDead(target) then local x, y, z = getElementPosition(target) spawnPlayer(target, x, y, z) outputChatBox ("You've Revived"..target, player, 0, 255, 0, false) outputChatBox (getPlayerName(player).."revived you", target, 0, 255, 0, false) end else outputChatBox("This player does no longer exist!", player) end end) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
EngMohamedLish Posted June 7, 2015 Author Share Posted June 7, 2015 Try this it should work addCommandHandler ("revive", function(player, cmd, player2) local target = getPlayerFromPartialName(player2) if target then if isPedDead(target) then local x, y, z = getElementPosition(target) spawnPlayer(target, x, y, z) outputChatBox ("You've Revived"..target, player, 0, 255, 0, false) outputChatBox (getPlayerName(player).."revived you", target, 0, 255, 0, false) end else outputChatBox("This player does no longer exist!", player) end end) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Yup, it works, but there's still a bug, I have setCameraMatrix already made, how can i stop it, when player be revived? I tried " setCameraTarget(player2, player2) but doesn't work. Link to comment
Walid Posted June 7, 2015 Share Posted June 7, 2015 try to use a timer setTimer(setCameraTarget,5000,1,player2, player2) Link to comment
EngMohamedLish Posted June 7, 2015 Author Share Posted June 7, 2015 try to use a timer setTimer(setCameraTarget,5000,1,player2, player2) Problem isn't about a timer, it is about a bug: Bad argument @ 'setCameraTarget' [Expected element at argument , got string 'super' That's what i get, when i use the command. Link to comment
Walid Posted June 7, 2015 Share Posted June 7, 2015 Replace player2 with target. and use my function. Link to comment
EngMohamedLish Posted June 7, 2015 Author Share Posted June 7, 2015 Replace player2 with target. and use my function. Nice, it needed to change player2 with target, Thanks solved Appreciate it. Link to comment
Walid Posted June 7, 2015 Share Posted June 7, 2015 Replace player2 with target. and use my function. Nice, it needed to change player2 with target, Thanks solved Appreciate it. np. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now