GamerDeMTA Posted July 11, 2013 Share Posted July 11, 2013 function equi ( ) local p = getPedStat ( player, 75 ) setPedStat ( player, 75, p + 500 ) end addEventHandler("onPlayerJoin", root, equi) Link to comment
denny199 Posted July 11, 2013 Share Posted July 11, 2013 SourceThe source of this event is the player who joined. Use "source" function equi ( ) local p = getPedStat ( source, 75 ) setPedStat ( source, 75, p + 500 ) end addEventHandler("onPlayerJoin", root, equi) Link to comment
Kenix Posted July 11, 2013 Share Posted July 11, 2013 (edited) player variable is not defined, you should use source in this case. http://development.mtasa.com/index.php? ... ent_system Edited July 11, 2013 by Guest Link to comment
PaiN^ Posted July 11, 2013 Share Posted July 11, 2013 I don't think that the script makes much sens, The stat of the player will allways be 0 on join !! Link to comment
GamerDeMTA Posted July 11, 2013 Author Share Posted July 11, 2013 It doesn't work yet. the debugscript gave "arithmetic attempt" or something like that with the old script. In line 3. Now , with source, it doesn't work and it dont give Debugscript 3 Link to comment
MOHAKO Posted July 11, 2013 Share Posted July 11, 2013 It doesn't work like this? function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) Link to comment
GamerDeMTA Posted July 11, 2013 Author Share Posted July 11, 2013 It doesn't work like this? function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) Yes now it works thanks. Oh and how to give the player + 100 stats per Kill? Link to comment
xXMADEXx Posted July 11, 2013 Share Posted July 11, 2013 function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) addEventHandler ( "onPlayerWasted", root, function ( _, source ) if ( source ) then local current = getPedStat ( source, 75 ) setPedStat ( source, 75, current + 100 ) else return end end ) Link to comment
myonlake Posted July 11, 2013 Share Posted July 11, 2013 function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) addEventHandler ( "onPlayerWasted", root, function ( _, source ) if ( source ) then local current = getPedStat ( source, 75 ) setPedStat ( source, 75, current + 100 ) else return end end ) The "else return" part is unnecessary since that side of the code is never being executed and would automatically return end if source wasn't true. Link to comment
GamerDeMTA Posted July 11, 2013 Author Share Posted July 11, 2013 @MADEXX It says attempt to perform arithmetic in the line 9. and it says is bad the line 8 too Link to comment
MOHAKO Posted July 11, 2013 Share Posted July 11, 2013 @MADEXX It says attempt to perform arithmetic in the line 9. and it says is bad the line 8 too function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) addEventHandler ( "onPlayerWasted", root, function ( _, source ) if ( source ) then local current = getPedStat ( source, 75 ) local new = current + 100 setPedStat ( source, 75, new ) else return end end ) try this. Link to comment
Lloyd Logan Posted July 11, 2013 Share Posted July 11, 2013 I don't think that the script makes much sens, The stat of the player will allways be 0 on join !! Yeah, he will have to getAccountData then setAccountData ! Link to comment
GamerDeMTA Posted July 11, 2013 Author Share Posted July 11, 2013 @MADEXX It says attempt to perform arithmetic in the line 9. and it says is bad the line 8 too function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) addEventHandler ( "onPlayerWasted", root, function ( _, source ) if ( source ) then local current = getPedStat ( source, 75 ) local new = current + 100 setPedStat ( source, 75, new ) else return end end ) try this. It doesn't work yet it gives error in the line of "local current" and "local new". Local new error is arithmetic. Link to comment
Renkon Posted July 11, 2013 Share Posted July 11, 2013 dont think it will work but try setting 100.0 instead of 100. Link to comment
GamerDeMTA Posted July 12, 2013 Author Share Posted July 12, 2013 No, it doesn't work. It says this: WARNING: Bad argument @ ' getPedStat' ERROR: attempt to perform arithmetic on global 'current' (a nil value) Link to comment
Castillo Posted July 12, 2013 Share Posted July 12, 2013 function equi ( ) setPedStat ( source, 75, 500 ) end addEventHandler ( "onPlayerJoin", root, equi ) addEventHandler ( "onPlayerWasted", root, function ( _, killer ) if ( killer and getElementType ( killer ) == "player" ) then local current = getPedStat ( killer, 75 ) setPedStat ( killer, 75, ( current + 100 ) ) end end ) Link to comment
GamerDeMTA Posted July 12, 2013 Author Share Posted July 12, 2013 It doesn't work yet. This is what debugscript 3 said me: Bad argument @ 'getElementType' [Expected element at argument 1, got number '28'] Link to comment
MOHAKO Posted July 12, 2013 Share Posted July 12, 2013 function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) function playerDeath(ammo, killer) if (killer) then if (getElementType(killer) == "player") then local old = getPedStat(killer, 75) local new = oldstat + 100 setPedStat(killer, 75, new) end end end addEventHandler("onPlayerWasted", root, playerDeath) Try this... Link to comment
Castillo Posted July 12, 2013 Share Posted July 12, 2013 It doesn't work yet. This is what debugscript 3 said me:Bad argument @ 'getElementType' [Expected element at argument 1, got number '28'] My script has to work, copy it exactly like I posted. @V.Krumins: That's the same thing as my script. Link to comment
iPrestege Posted July 12, 2013 Share Posted July 12, 2013 function equi() setPedStat(source, 75, 500) end addEventHandler("onPlayerJoin", root, equi) function playerDeath(ammo, killer) if (killer) then if (getElementType(killer) == "player") then local old = getPedStat(killer, 75) local new = oldstat + 100 setPedStat(killer, 75, new) end end end addEventHandler("onPlayerWasted", root, playerDeath) Try this... oldstat = ? Link to comment
GamerDeMTA Posted July 12, 2013 Author Share Posted July 12, 2013 It doesn't work yet. This is what debugscript 3 said me:Bad argument @ 'getElementType' [Expected element at argument 1, got number '28'] My script has to work, copy it exactly like I posted. @V.Krumins: That's the same thing as my script. Thanks it works! Oh and u know it how to do it also when u kill zombies? Link to comment
iPrestege Posted July 12, 2013 Share Posted July 12, 2013 Use : 'onZombieWasted' Event : addEvent addEventHandler Link to comment
GamerDeMTA Posted July 12, 2013 Author Share Posted July 12, 2013 It doesn't work. addEventHandler ( "onZombieWasted", root, function ( _, killer ) if ( killer and getElementType ( killer ) == "player" ) then local current = getPedStat ( killer, 75 ) setPedStat ( killer, 75, ( current + 100 ) ) end end ) addEvent ("onZombieWasted" 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