Jump to content

Xwad

Members
  • Posts

    1,089
  • Joined

  • Last visited

Everything posted by Xwad

  1. Is the event now good? And what do you mean by defined? addEventHandler("onClientVehicleWeaponFire", getLocalVehicle(), onClientVehicleWeaponFireFunc)
  2. i have convert the example. is it now good or i goind the bad way? -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if vehicle == 601 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)
  3. do you mean this? becaouse this makes only possible to shoot rockets with minigun -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 38 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)
  4. Can you write here an example possibly please?
  5. Hi! If I want to make a script that allows to shot with s.w.a.t. vehicle like a rhino then I need to use the CreateProjectile function??Thanks!
  6. why? what this script makes?
  7. Hi i have a script that makes possible to mount a minigun to a vehicle but id does not work. server.lua local guns = 38 { [470] = { ["xPosOffset"] = 1.0, ["yPosOffset"] = 0, ["zPosOffset"] = 0 } } function attachMod(playerSource, commandName) local vehicle = getPlayerOccupiedVehicle(playerSource) local gun = false if (vehicle) then gun = guns[getVehicleID(vehicle)] or false if (gun) then attachElementToElement(createObject(2985, 0, 0, -100, 0, 0, 0), vehicle, gun.xPosOffset, gun.yPosOffset, gun.zPosOffset, 0, 0, 90) setElementData(vehicle, "toggleVehicleWeapon", true) end end end function detachMod(playerSource, commandName) local vehicle = getPlayerOccupiedVehicle(playerSource) if (vehicle) then for _, element in ipairs(getAttachedElements(vehicle)) do destroyElement(element) end setElementData(vehicle, "toggleVehicleWeapon", false) end end addCommandHandler("/attachmod", attachMod, false) addCommandHandler("/detachmod", detachMod, false) client.lua local root = getRootElement() local player = getLocalPlayer() local toggleVehicleWeapon = false local previousTick = getTickCount() local projectileType = 21 function updateVehicleWeapon(source, dataName) if (getElementType(source) == "vehicle" and dataName == "toggleVehicleWeapon") then toggleVehicleWeapon = (getElementData(source, dataName) and isPlayerInVehicle(player)) end end function callbackDataChange(dataName) updateVehicleWeapon(source, dataName) end
  8. How can i make a field gun script?? i need it for my server its very imprortant. Thanks
  9. is it so good? function equalTwoRandomVehiclesVelocity() if getVehicleCount() < 2 then -- If there's only one player (or no players) this doesn't make sense return false end local randomVehicle1, randomVehicle2 = getRandomVehicle(), getRandomVehicle() -- Get two random players while randomVehicle1 == randomVehicle2 do -- Make sure the two players are different randomVehicle2 = getRandomPlayer() end local speedx, speedy, speedz = getElementVelocity (randomVehicle1) -- Get the velocity of the first random player setElementVelocity(randomVehicle2, speedx, speedy, speedz) -- Copy that velocity to the second random player outputChatBox("Now " .. getVehicleName(randomVehicle2) .. " runs as fast as " .. getVehicleName(randomVehiclePlayer1) .. "!", root, 255, 128, 0) return true end
  10. ohh no that is for ped not for vehicle
  11. this? function equalTwoRandomPlayersVelocity() if getPlayerCount() < 2 then -- If there's only one player (or no players) this doesn't make sense return false end local randomPlayer1, randomPlayer2 = getRandomPlayer(), getRandomPlayer() -- Get two random players while randomPlayer1 == randomPlayer2 do -- Make sure the two players are different randomPlayer2 = getRandomPlayer() end local speedx, speedy, speedz = getElementVelocity (randomPlayer1) -- Get the velocity of the first random player setElementVelocity(randomPlayer2, speedx, speedy, speedz) -- Copy that velocity to the second random player outputChatBox("Now " .. getPlayerName(randomPlayer2) .. " runs as fast as " .. getPlayerName(randomPlayer1) .. "!", root, 255, 128, 0) return true end
  12. Hi how can i make rhinos speed slowlyer in mta?
  13. Xwad

    Team weapon shop

    but your server is very cool!
  14. Xwad

    Team weapon shop

    sry if i downloaded it im not know that its not allow. I delete it
  15. Xwad

    Team weapon shop

    i downloaded it from the community
  16. Xwad

    Team weapon shop

    why is it a problem that i use your weaponshop?
  17. Xwad

    Team weapon shop

    its a cool script i made 2 maerker and i replaced the guns and it works. But i have a problem when i passed over the marker then there i cant buy the shotgun i click on it and nothing happens. The other weapons works only the shotgun has error. here is the code : Client.lua local marker = createMarker(222.2, 1866.1, 13.1,"cylinder",2.0,0,255,0,255) function draw() base = dxDrawRectangle(358, 185, 456, 385, tocolor(1, 3, 0, 150), false) dxDrawLine(358, 445, 811, 445, tocolor(255, 255, 255, 255), 1, false) dxDrawText("Weapon Shop", 462, 195, 709, 241, tocolor(0, 255, 0, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Weapon Shop By Shaman\nCopyright By Shaman 2015", 363, 466, 522, 556, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Close", 700, 518, 825, 562, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Browning", 377, 297, 487, 347, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Bazooka", 545, 300, 657, 344, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Shotgun", 701, 300, 825, 347, tocolor(255, 255, 255, 255), 1.10, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Colt 1911", 373, 379, 483, 429, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Thompson", 547, 379, 657, 429, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Sniper", 701, 379, 811, 429, tocolor(255, 255, 255, 255), 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Cost-2000$", 387, 342, 482, 357, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Cost-2000$", 552, 342, 647, 357, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Cost-850$", 716, 342, 811, 357, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Cost-2000$", 387, 424, 482, 439, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Cost-2000$", 547, 424, 642, 439, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Cost-2000$", 716, 424, 811, 439, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) showcursor (true) end button = guiCreateButton(532, 294, 105, 42, "Shotgun-1800$", true) button2 = guiCreateButton(368, 294, 105, 42, "Browning-6000$", false) button3 = guiCreateButton(699, 294, 105, 42, "rocketlauncher-3500$", false) button4 = guiCreateButton(368, 380, 105, 42, "Colt 1911-500$", false) button5 = guiCreateButton(532, 380, 105, 42, "Thompson-2800$", false) button6 = guiCreateButton(699, 380, 105, 42, "Sniper-3500$", false) button7 = guiCreateButton(691, 523, 110, 37, "Close", false) guiSetVisible(button2, false) guiSetVisible(button3, false) guiSetVisible(button4, false) guiSetVisible(button5, false) guiSetVisible(button6, false) guiSetVisible(button7, false) guiSetVisible(button, false) local drawingPanel = false; function startDrawing_CMD() if(drawingPanel == false) then addEventHandler("onClientPreRender", getRootElement(), draw); guiSetVisible(button, true) drawingPanel = true; showCursor(true) else removeEventHandler("onClientPreRender", getRootElement(), draw); guiSetVisible(button, false) drawingPanel = false; showCursor(false) end end addEventHandler("onClientMarkerHit", marker, function (p) if p == localPlayer then count = 10 addEventHandler("onClientPreRender", getRootElement(), draw); guiSetVisible(button, true) guiSetVisible(button2, true) guiSetVisible(button3, true) guiSetVisible(button4, true) guiSetVisible(button5, true) guiSetVisible(button6, true) guiSetVisible(button7, true) guiSetAlpha(button, 0) guiSetAlpha(button2, 0) guiSetAlpha(button3, 0) guiSetAlpha(button4, 0) guiSetAlpha(button5, 0) guiSetAlpha(button6, 0) guiSetAlpha(button7, 0) showCursor(true) end end ) addEventHandler("onClientGUIClick",button7,function() if ( source == button7) then removeEventHandler("onClientPreRender", getRootElement(), draw); guiSetVisible(button, false) guiSetVisible(button2, false) guiSetVisible(button3, false) guiSetVisible(button4, false) guiSetVisible(button5, false) guiSetVisible(button6, false) guiSetVisible(button7, false) showCursor(false) end end ) addEventHandler("onClientGUIClick",button2,function() if ( source == button2) then showCursor(true) triggerServerEvent ("giveweaponak47",getLocalPlayer(),giveweaponak47) end end ) addEventHandler("onClientGUIClick",button5,function() if ( source == button5) then showCursor(true) triggerServerEvent ("giveweapontec9",getLocalPlayer(),giveweapontec9) end end ) addEventHandler("onClientGUIClick",button3,function() if ( source == button3) then showCursor(true) triggerServerEvent ("giveweaponrocketlauncher",getLocalPlayer(),giveweaponrocketlauncher) end end ) addEventHandler("onClientGUIClick",button4,function() if ( source == button4) then showCursor(true) triggerServerEvent ("giveweaponcolt45",getLocalPlayer(),giveweaponcolt45) end end ) addEventHandler("onClientGUIClick",button6,function() if ( source == button6) then showCursor(true) triggerServerEvent ("giveweaponsniper",getLocalPlayer(),giveweaponsniper) end end ) addEventHandler("onClientGUIClick",button,function() if ( source == button) then showCursor(true) triggerServerEvent ("giveweaponshotgun",getLocalPlayer(),giveweaponshotgun) end end ) server.lua addEvent("giveweaponak47",true) addEventHandler("giveweaponak47",root, function() if ( getPlayerMoney (source) >= 6000 ) then takePlayerMoney(source, 6000) giveWeapon (source,30,150,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end) addEvent("giveweaponshotgun",true) addEventHandler("giveweaponshotgun",root, function() if ( getPlayerMoney (source) >= 1800 ) then takePlayerMoney(source, 1800) giveWeapon (source,25,40,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end) addEvent("giveweaponcolt45",true) addEventHandler("giveweaponcolt45",root, function() if ( getPlayerMoney (source) >= 500 ) then takePlayerMoney(source, 500) giveWeapon (source,22,40,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end) addEvent("giveweaponrocketlauncher",true) addEventHandler("giveweaponrocketlauncher",root, function() if ( getPlayerMoney (source) >= 3500 ) then takePlayerMoney(source, 3500) giveWeapon (source,35,5,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end) addEvent("giveweaponsniper",true) addEventHandler("giveweaponsniper",root, function() if ( getPlayerMoney (source) >= 3500 ) then takePlayerMoney(source, 3500) giveWeapon (source,34,40,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end) addEvent("giveweapontec9",true) addEventHandler("giveweapontec9",root, function() if ( getPlayerMoney (source) >= 2800 ) then takePlayerMoney(source, 2800) giveWeapon (source,32,80,true) else outputChatBox('You don\'t have enough money to buy this weapon.', source, 255, 0, 0 ) end end)
  18. Xwad

    Team vehicles

    ok i have read it and i made this script #include enum team_vehicle_info { v_id,//the vehicle id v_team,//the vehicle's team id bool:v_exist//boolean to check if vehicle exists } new team_vehicle[ MAX_VEHICLES ][ team_vehicle_info ]; main() { for(new slot; slot < MAX_VEHICLES; slot++) { team_vehicle[slot][v_id] = -1;//set to invalide vehicle model id team_vehicle[slot][v_team] = NO_TEAM;//set for NO_TEAM team_vehicle[slot][v_exist] = false;//the vehicle don't exist } } stock CreateVehicleForTeam(teamid, vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay) { if(teamid == NO_TEAM) return false; // if the vehicle teamid is NO_TEAM(255), then this function won't work for(new slot; slot < MAX_VEHICLES; slot++) { if(team_vehicle[slot][v_exist] == false)//checks if the vehicle is not created, then only proceed or else catch another loop case! { //creat the main vehicle and store its id team_vehicle[slot][v_id] = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay); team_vehicle[team_vehicle[slot][v_id]][v_team] = teamid;//storing the teamid team_vehicle[team_vehicle[slot][v_id]][v_exist] = true;//setting created value "yes", so this says that the vehicle is created! return team_vehicle[slot][v_id];//returns the vehicle id } } return true; } stock DestoryVehicleForTeam(vehicleid) { DestroyVehicle(vehicleid);//destorying the vehicle team_vehicle[vehicleid][v_team] = NO_TEAM;//set for NO_TEAM team_vehicle[vehicleid][v_exist] = false;//the vehicle don't exist return true; } public OnGameModeInit() { CreateVehicleForTeam(0, 413, 327.8443, -1809.2729, 4.5733, 359.3342, 91, 1, 0);//team vehicle for teamid 0 CreateVehicleForTeam(0, 467, 740.4370, -1793.5476, 12.9180, 349.2087, 58, 8, 0);//team vehicle for teamid 0 CreateVehicleForTeam(1, 473, 823.7594, -2066.2686, -0.1017, 112.6381, 56, 53,0);//team vehicle for teamid 1 CreateVehicleForTeam(1, 467, 892.0507, -1797.3351, 13.4070, 175.4098, 60, 1, 0);//team vehicle for teamid 1 return 1; } public OnGameModeExit() { DestoryVehicleForTeam(0); DestoryVehicleForTeam(1); DestoryVehicleForTeam(2); DestoryVehicleForTeam(3); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)//Player entered a vehicle as a driver { new vehicleid = GetPlayerVehicleID(playerid); for(new slot; slot < MAX_VEHICLES; slot++) { if(team_vehicle[slot][v_exist] && vehicleid == team_vehicle[slot][v_id])//if vehicle is a team vehicle! { if(GetPlayerTeam(playerid) != team_vehicle[slot][v_team])//if team id don't matches { RemovePlayerFromVehicle(playerid);//remove the player from vehicle GameTextForPlayer(playerid, "~r~You can't enter other team's vehicle", 3000, 3);//send the player a message } } } } return 1; }
  19. Xwad

    Team vehicles

    when i enter the tank then the game say "someone stole a rhino!"
×
×
  • Create New...