0 Members and 4 Guests are viewing this topic.
function OnPlayerCommand(ID: Byte; Text: string): boolean;var i: integer;begin if Text = '/mercy' then begin for i := 1 to 1 do begin if GetPlayerStat(i, 'active') then Command('/kill '+GetPlayerStat(ID, 'Name')); end; end;end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if Text = '/mercy' then begin Command('/kill '+GetPlayerStat(ID, 'Name')); end; end;
if GetPlayerStat(ID,'Alive) = true then if GetPlayerStat(ID,'Primary') = 15 then DoDamage(ID,6666);
This one's better:[...]
Function OnPlayerCommand(ID: Byte; Text: String); Begin Text := LowerCase(Text); if Text = '/mercy' Then Begin if GetPlayerStat(ID,'Alive') = True Then if GetPlayerStat(ID,'Primary') = 15 Then DoDamage(ID,6666); end;end;
Quote from: Gizd on April 10, 2010, 10:49:01 amThis one's better:[...]You forgot the closing ' after "Alive"..Complementing Gizd's Script..Code: [Select]Function OnPlayerCommand(ID: Byte; Text: String); Begin Text := LowerCase(Text); if Text = '/mercy' Then Begin if GetPlayerStat(ID,'Alive') = True Then if GetPlayerStat(ID,'Primary') = 15 Then DoDamage(ID,6666); end;end;
No no no no no NO.Listen, and listen careful, for I will only explain this once (although several other people will probably do it too).OnPlayerCommand(ID: Byte; Text: String);ID is the ID of the player who typed a command.Text is the command that they sent.Therefore, imagine if player 3 typed /mercy, the ScriptCore would call OnPlayerCommand with ID being 3 and Text being '/mercy'. You do NOT have to use a for loop to determine which player to kill, because you get given the player's ID when the function itself is called.That is why the for loop is not only useless, it also creates a logical error in your script, because, in the first example, you're checking to see if the first player is alive, and THEN killing the player who sent it, so if player 1 is dead, player 3 wouldn't be killed when he types '/mercy'.In the second example you provided for your want of a for loop, you're now checking against all players to see if any one of them are alive. That means you'll be killing him each time you find a player alive. If you have a 12 slot server, and everyone is alive, and someone does /mercy, he's gonna get killed 11 times in that situation. Or, if I've misunderstood how many times you want to use that i variable, doing your second example could result in a script that kills ALL players when one types /mercy.Moral of the story (also TL;DR): Don't use a for loop for this script.
Lol.. why use DoDamage if you can just use /kill id ?
Just lik DorkeyDear said, /kill command writes a message to all players.DoDamage() doesnt.Just go DoDamage(ID,4000); that it kills player right on time :]
Well, a bad idea. They'll flood chat with these stupid shiny messages...If someone wants to try it - why not?
Quote from: Neosano on April 11, 2010, 04:18:14 pmWell, a bad idea. They'll flood chat with these stupid shiny messages...If someone wants to try it - why not?I am with you.When players look at the death console, they will be all like, omg, did he died trying to do /mercy ?Then they go and do /mercy.And they die.And then more noobs try to do /mercy, and there it goes.
function OnPlayerCommand(ID: Byte; Text: string): boolean; beginif Text = '/mercy' then beginDoDamage(ID,ID,8001);WriteConsole(ID,'Dont do that.',$EE81FAA1);WriteConsole(0,'Dont /mercy kids. '+ IDToName(ID) +' learned why.' ,$EE81FAA1);SetScore(ID,0);end;end;
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.
function OnPlayerCommand(ID: Byte; Text: string): boolean; beginif Text = '/mercy' then beginCommand('/kill ' + ID);WriteConsole(ID,'Dont do that.',$EE81FAA1);WriteConsole(0,'Dont /mercy kids. '+ IDToName(ID) +' learned why.' ,$EE81FAA1);SetScore(ID,0);end;end;