vanishSHC Posted January 13, 2011 Share Posted January 13, 2011 Hello, I have a script where I have 3 teams. 1. Police 2. Medical 3. Repo Now I am using p-spawn for the initial spawn, Teamless people are homeless and spawn in grove street However, I want to make it so that in my function for the join team i.e joinpolice it kills the player and spawns them elsewhere( i.e. police station) . Now that part is the easy part... the question is... when they die... i dont want them being sent to grove street. (because p-spawn has a function for that...) However, I dont really want to destroy the p-spawn script. So i was wondering if there was a easy way to attach an if then statement with getPlayerFromTeam or similar function to make it so if the police die they go right back to where i initially spawned them when they joined the team. If the player isnt on a team, p-spawn will kick in and send them to grove street. Here is my current code. First script, Server Sided, makes the team. the end: function createTeamsOnStart () createTeam ( "Police", 0, 0, 255 ) createTeam ( "Medical", 255, 0, 0 ) createTeam ( "Vehicle Repossession", 255, 255, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) Second script, join command handlers takeaway weapons and then give specific weapons for that team and sets the skin and what not: --Teamless Weapons aka hobo local hoboWeapon = 30 local hoboAmmo = 2000 local hoboOtherWeapon = 24 local hoboOtherAmmo = 2000 --Police Weapons local copWeapon = 25 local copAmmo = 2000 local copOtherWeapon = 22 local copOtherAmmo = 2000 local copStick = 3 --Medical Weapons local medWeapon = 23 local medAmmo = 2000 local medOtherWeapon = 14 --Repo Weapons local repoWeapon = 32 local repoAmmo = 2000 local repoOtherWeapon = 5 --Add more vars function joincops(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Police")) setElementModel(source, 280) takeAllWeapons (source) giveWeapon(source, copWeapon, copAmmo) giveWeapon(source, copStick) giveWeapon(source, copOtherWeapon, copOtherAmmo) end addCommandHandler ("joinpolice",joincops) function joindocs(source) setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Medical")) setElementModel(source, 275) takeAllWeapons (source) giveWeapon(source, medWeapon, medAmmo) giveWeapon(source, medOtherWeapon) end addCommandHandler ("joinmedical",joindocs) function joinreposs(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Vehicle Repossession")) setElementModel(source, 50) takeAllWeapons (source) giveWeapon(source, repoWeapon, repoAmmo) giveWeapon(source, repoOtherWeapon) end addCommandHandler ("joinrepo",joinreposs) function quitteam(source) setPlayerTeam" class="kw6">setPlayerTeam (source, nil) setElementModel(source, 230) takeAllWeapons (source) giveWeapon(source, hoboWeapon, hoboAmmo) giveWeapon(source, hoboOtherWeapon, hoboOtherAmmo) end addCommandHandler ("quitteam",quitteam) I was just wondering if anyone knew how to go about this painlessly P.S. i didnt add the kill player and spawn points yet. P.S again: Don't know whats up with that kw6 shit being added so ignore it Link to comment
Castillo Posted January 13, 2011 Share Posted January 13, 2011 use setElementPosition? after he spawns you will be moved to correct "spawn point". https://wiki.multitheftauto.com/wiki/SetElementPosition Link to comment
SDK Posted January 13, 2011 Share Posted January 13, 2011 Did you try using spawnPlayer? That should work even on alive players iirc. function quitteam(source) spawnPlayer (source, hoboSpawnX, hoboSpawnY, hoboSpawnZ, hoboSpawnRotation, 230) giveWeapon(source, hoboWeapon, hoboAmmo) giveWeapon(source, hoboOtherWeapon, hoboOtherAmmo) end addCommandHandler ("quitteam",quitteam) Link to comment
vanishSHC Posted January 14, 2011 Author Share Posted January 14, 2011 Okay so here is the updated code with SDK's suggestion... SetElementPosition would be a viable option as well and might incorporate it with other events rather than the initial spawn. I disabled P-spawn to program my own initial gui team selection screen, and to allow the script below to function, however. it doesnt function. --Teamless Weapons aka hobo local hoboWeapon = 30 local hoboAmmo = 2000 local hoboOtherWeapon = 24 local hoboOtherAmmo = 2000 --Police Weapons local copWeapon = 25 local copAmmo = 2000 local copOtherWeapon = 22 local copOtherAmmo = 2000 local copStick = 3 --Medical Weapons local medWeapon = 23 local medAmmo = 2000 local medOtherWeapon = 14 --Repo Weapons local repoWeapon = 32 local repoAmmo = 2000 local repoOtherWeapon = 5 --Spawn Grouping local hoboSpawnX = 2494 local hoboSpawnY = -1666 local hoboSpawnZ = 14 local hoboSpawnRotation = 0 local copSpawnX = 1554.05 local copSpawnY = -1791.14 local copSpawnZ = 13.3 local copSpawnRotation = 270 local medSpawnX = 2038.23 local medSpawnY = -1411.24 local medSpawnZ = 17.1 local medSpawnRotation = 0 local repoSpawnX = 1604.40 local repoSpawnY = -1791.14 local repoSpawnZ = 13.3 local repoSpawnRotation = 0 --join spawnhandler function joincops(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Police")) spawnPlayer (source, copSpawnX, copSpawnY, copSpawnZ, copSpawnRotation, 280) takeAllWeapons (source) giveWeapon(source, copWeapon, copAmmo) giveWeapon(source, copStick) giveWeapon(source, copOtherWeapon, copOtherAmmo) end addCommandHandler ("joinpolice",joincops) --deadspawnhandler function spawndeadcops(source) playerteam = getPlayerTeam" class="kw2">getPlayerTeam(source) if (playerteam == getTeamFromName("Police")) then takeAllWeapons (source) spawnPlayer (source, copSpawnX, copSpawnY, copSpawnZ, copSpawnRotation, 280) giveWeapon(source, copWeapon, copAmmo) giveWeapon(source, copStick) giveWeapon(source, copOtherWeapon, copOtherAmmo) end end addEventHandler ( "onClientPlayerWasted", getRootElement(), spawndeadcops ) --join spawnhandler function joindocs(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Medical")) spawnPlayer (source, medSpawnX, medSpawnY, medSpawnZ, medSpawnRotation, 275) takeAllWeapons (source) giveWeapon(source, medWeapon, medAmmo) giveWeapon(source, medOtherWeapon) end addCommandHandler ("joinmedical",joindocs) --deadspawnhandler function spawndeaddocs(source) playerteam = getPlayerTeam" class="kw2">getPlayerTeam(source) if (playerteam == getTeamFromName("Medical")) then takeAllWeapons (source) spawnPlayer (source, medSpawnX, medSpawnY, medSpawnZ, medSpawnRotation, 280) giveWeapon(source, medWeapon, medAmmo) giveWeapon(source, medOtherWeapon) end end addEventHandler ( "onClientPlayerWasted", getRootElement(), spawndeaddocs ) function joinreposs(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, getTeamFromName("Vehicle Repossession")) spawnPlayer (source, repoSpawnX, repoSpawnY, repoSpawnZ, repoSpawnRotation, 50) takeAllWeapons (source) giveWeapon(source, repoWeapon, repoAmmo) giveWeapon(source, repoOtherWeapon) end addCommandHandler ("joinrepo",joinreposs) --deadspawnhandler function spawndeadreposs(source) playerteam = getPlayerTeam" class="kw2">getPlayerTeam(source) if (playerteam == getTeamFromName("Vehicle Repossession")) then takeAllWeapons (source) spawnPlayer (source, repoSpawnX, repoSpawnY, repoSpawnZ, repoSpawnRotation, 280) giveWeapon(source, repoWeapon, repoAmmo) giveWeapon(source, repoOtherWeapon) end end addEventHandler ( "onClientPlayerWasted", getRootElement(), spawndeadreposs ) function quitteam(source) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (source, nil) setElementModel(source, 230) takeAllWeapons (source) giveWeapon(source, hoboWeapon, hoboAmmo) giveWeapon(source, hoboOtherWeapon, hoboOtherAmmo) spawnPlayer (source, hoboSpawnX, hoboSpawnY, hoboSpawnZ, hoboSpawnRotation, 230) giveWeapon(source, hoboWeapon, hoboAmmo) giveWeapon(source, hoboOtherWeapon, hoboOtherAmmo) end addCommandHandler ("quitteam",quitteam) function spawndeadhobo(source) playerteam = getPlayerTeam" class="kw2">getPlayerTeam(source) if (playerteam == getTeamFromName(nil)) then takeAllWeapons (source) spawnPlayer (source, hoboSpawnX, hoboSpawnY, hoboSpawnZ, hoboSpawnRotation, 280) giveWeapon(source, hoboWeapon, hoboAmmo) giveWeapon(source, hoboOtherWeapon) end end addEventHandler ( "onClientPlayerWasted", getRootElement(), spawndeadhobo ) Seems like the Dead Players do not spawn instead they revert to the initial play/freeroam spawn. If i can get this working i can incorporate it into a gui hopefully somehow But thats a different story. Anyone got any idea why this wouldnt work? No output errors in the console. Thanks for all your help! 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