Jump to content

Why couldnt scripting be like this!


KraZ

Recommended Posts

Why couldnt scripting be like this!

I mean imagine it!

When a player dies, give the attacker 3 exp points; 
When a player gets 100 exp points then level him up 1 level; 
  
When a player dies, give the attacker 100 money; 
When a player joins, give them a random team between( "blue" , "red" ); 
When a player dies, show the attacker for 5 seconds; 
When a player dies. display on screen in small text on the right hand side the attacker name and weapon he used; 

Link to comment

Simple.

The computer doesn't know how to think as a human, it just cannot read a sentence like that. To make that kind of scripting you'd probably mess up your head into programming by lots of years.

Also Lua scripting is pretty simple compared to real programming. If you focus into learning and practice some, you may be able to do many cool things.

Link to comment
Also Lua scripting is pretty simple compared to real programming. If you focus into learning and practice some, you may be able to do many cool things.

Design. Real programming just has a little more responsibility.

When a player dies, give the attacker 3 exp points;

When a player gets 100 exp points then level him up 1 level;

 

When a player dies, give the attacker 100 money;

When a player joins, give them a random team between( "blue" , "red" );

When a player dies, show the attacker for 5 seconds;

When a player dies. display on screen in small text on the right hand side the attacker name and weapon he used;

Is possible, for scripting. In programming the logic would be too vague at times, and no one would want to use it. I certainly wouldn't.

Link to comment
Why couldnt scripting be like this!

I mean imagine it!

When a player dies, give the attacker 3 exp points; 
When a player gets 100 exp points then level him up 1 level; 
  
When a player dies, give the attacker 100 money; 
When a player joins, give them a random team between( "blue" , "red" ); 
When a player dies, show the attacker for 5 seconds; 
When a player dies. display on screen in small text on the right hand side the attacker name and weapon he used; 

no offence, but lua is a really easy language. If you can't learn it you are quite stupid.

I mean, the language(lua) is self explanatory and almost as you write above lol.

Link to comment

You could make your own script that can read sentences and make a script of it, but the biggest problem is that you cant make advanced scripts like that so its pretty much useless if you want to make awesome scripts.

Link to comment

This sentence:

When a player dies, give the attacker 3 exp points; 
When a player gets 100 exp points then level him up 1 level; 
  
When a player dies, give the attacker 100 money; 
When a player joins, give them a random team between( "blue" , "red" ); 
When a player dies, show the attacker for 5 seconds; 
When a player dies. display on screen in small text on the right hand side the attacker name and weapon he used; 

in Script:

--Server-side 
addEventHandler("onPlayerWasted",root,function(_,attacker) --When a player dies 
    if(attacker~=source)then 
        setElementData(attacker,"Points",getElementData(attacker,"Points")+3) --give the attacker +3 exp points 
        givePlayerMoney(attacker,100) --give the attacker 100 money 
        setCameraTarget(source,attacker) --show the attacker for 5 seconds 
        setTimer(setCameraTarget,5000,1,source,source) 
        if(attackerPnts==100)then --When a player gets 100 exp points then 
            setElementData(attacker,"Level",getElementData(attacker,"Level")+1) --level them up +1 level 
        end 
    end 
end) 
addEventHandler("onPlayerJoin",root,function() --When a player joins 
    local teams = {"blue","red"} 
    setPlayerTeam(source,getTeamFromName(unpack(teams))) --give them a random team between( "blue" , "red" ) 
end) 
--Client-side 
addEventHandler("onClientPlayerWasted",root,function(killer,wep) --When a player dies 
    if(killer~=source)then 
        local wepName = getWeaponNameFromID(wep) 
        if(isElement(killLbl) and isElement(wepLbl))then 
            guiSetText(killLbl,"Killer: "..killer) 
            guiSetText(wepLbl,"Killer: "..wepName) 
        else 
            local screenWidth, screenHeight = guiGetScreenSize() 
            local windowWidth, windowHeight = 300, 100 
            killLbl=guiCreateLabel((screenHeight/3 - windowHeight/3),(screenWidth/3 - windowWidth/3),windowWidth,windowHeight,"Killer: "..killer,false) --display on screen in small text on the right hand side the attacker name 
            wepLbl=guiCreateLabel((screenHeight/4 - windowHeight/4),(screenWidth/3 - windowWidth/3),windowWidth,windowHeight,"Weapon: "..wepName,false) --and weapon he used 
        end 
    end 
end) 
addEventHandler("onClientPlayerSpawn",root,function() 
    if(isElement(killLbl) and isElement(wepLbl))then 
        destroyElement(killLbl) 
        destroyElement(wepLbl) 
    end 
end) 

Edited by Guest
Link to comment

It can, if you want.

@@Jaysds1,

setElementData(attacker,"Points",getElementData(attacker,"Points")+3) 

First time, element data Points doesn't, so it will be false. You must check if it is set.

Also variable attackerPnts is not defined and...

    setPlayerTeam(source,getTeamFromName(unpack(teams[math.random(#teams)]))) 

unpack function is not needed here.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...