wc3edit.net

United Warcraft 3 map hacking!
It is currently March 19th, 2024, 8:54 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: April 17th, 2020, 7:49 am 
Offline
Junior Member
User avatar

Joined: April 4th, 2020, 5:25 pm
Posts: 42
I tried with logic, but it still can't, can you tell me what's missing from the command that I made?

Code:
function beta_test takes nothing returns nothing
    local player beta_trigger = GetTriggerPlayer()
    local string beta_chat = GetEventPlayerChatString()
    local string beta_cmd = SubString(src,0,6)
    local unit beta_unit
    if(beta_cmd == "-item ")then
        call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99)
    endif
endfunction
function beta_item_init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 24
        call TriggerRegisterPlayerChatEvent(t, Player(i), "-item ", false)
        set i = i + 1
    endloop
    call TriggerAddAction(t, function beta_test)
    set t = null
endfunction
function main takes nothing returns nothing
    call beta_item_init()
endfunction


other test command
Code:
function beta_test takes nothing returns nothing
    local player beta_trigger = GetTriggerPlayer()
    local string beta_chat = GetEventPlayerChatString()
    local string beta_cmd = SubString(src,0,6)
    local unit beta_unit
    if(beta_cmd == "-item ")then
        call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99)
    endif
endfunction
function main takes nothing returns nothing
    call beta_test()
endfunction


other test #2
Code:
function beta_test takes nothing returns nothing
    local player beta_trigger = GetTriggerPlayer()
    local string beta_chat = GetEventPlayerChatString()
    local string beta_cmd = SubString(src,0,6)
    local unit beta_unit
    if(beta_cmd == "-item ")then
        call SetItemCharges(UnitAddItemByIdSwapped('I001',beta_unit),99)
    endif
    set beta_trigger=null
    set beta_chat=null
    set beta_cmd=null
    set betaunit=null
endfunction
function beta_item_init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 24
        call TriggerRegisterPlayerChatEvent(t, Player(i), "-item ", false)
        set i = i + 1
    endloop
    call TriggerAddAction(t, function beta_test)
    set t = null
endfunction
function main takes nothing returns nothing
    call beta_item_init()
endfunction

Sorry if I asked a lot, oot from the forum rules, if possible please rewrite this script so that I can understand, thank you. My respect to the forum wc3edit.net forum.

Sorry if my posts double posts / triple posts, if my posts violate the rules tell me and delete my posts, if possible don't ban me T ^ T. thank you.


Top
 Profile  
 
PostPosted: April 17th, 2020, 8:39 am 
Offline
Also Not an Admin, but closer than devoltz
User avatar

Joined: February 14th, 2018, 5:35 am
Posts: 1791
Title: Just Another S.Mod
You definitely don't know what you are doing. lol. That will never work because there's no unit and the way you used TriggerRegisterPlayerChatEvent is totally wrong.

Just copy and paste it:

globals
Code:
unit CC_Unit = null
group CC_Group = CreateGroup( )


endglobals
Code:
function ChatEvent takes trigger Trig, string Text, boolean Bool, code Act returns trigger
local integer index = 0
   loop
      call TriggerRegisterPlayerChatEvent( Trig, Player( index ), Text, Bool )
      set index = index + 1
   exitwhen index == bj_MAX_PLAYER_SLOTS
   endloop
   if Act != null then
      call TriggerAddAction( Trig, Act )
   endif
return Trig
endfunction
function FindEmptyString takes integer Begin, string Text returns integer
local integer i = Begin
   loop
      if SubString( Text, i, i + 1 ) == " " then
         return i
      endif
   exitwhen i == StringLength( Text )
   set i = i + 1
   endloop
return StringLength( Text )
endfunction
function SelectedUnit takes player target returns unit
set CC_Unit = null
call GroupEnumUnitsSelected( CC_Group, target, null )
set CC_Unit = FirstOfGroup( CC_Group )
call GroupClear( CC_Group )
return CC_Unit
endfunction
function CommandsHandler takes nothing returns nothing
local integer pid = GetPlayerId( GetTriggerPlayer( ) )
local string text = SubString( GetEventPlayerChatString( ), 1, StringLength( GetEventPlayerChatString( ) ) )
local integer emptyat = FindEmptyString( 0, text )
local string command = StringCase( SubString( text, 0, emptyat ), false )

call SelectedUnit( Player( pid ) )

if command == "item" then
   call SetItemCharges( UnitAddItemByIdSwapped (ID GOES HERE, CHANGE! DON'T FORGET TO USE APOSTROPHE ( Example: 'itemid' ), CC_Unit), 99 )
endif
endfunction
function CCommands_Init takes nothing returns nothing
call ChatEvent( CreateTrigger( ), "-", false, function CommandsHandler )
endfunction


function main
Code:
call CCommands_Init( )


Simple and clean. There's a way to make it without globals, but whatever. Just use that way for now. :lol:


Top
 Profile  
 
PostPosted: April 17th, 2020, 9:59 am 
Offline
Junior Member
User avatar

Joined: April 4th, 2020, 5:25 pm
Posts: 42
nuzamacuxe wrote:
You definitely don't know what you are doing. lol. That will never work because there's no unit and the way you used TriggerRegisterPlayerChatEvent is totally wrong.

...

Simple and clean. There's a way to make it without globals, but whatever. Just use that way for now. :lol:


I tried to follow this page:
http://forum.wc3edit.net/fulfilled-requ ... 37306.html

in this code I use logic :( =
owner123 wrote:
There's no point requesting a single command btw, it's easier to just add a full cheatpack.
But I actually love writing code so I made a custom command anyways.

Type -gold x to receive x gold
(i.e. -gold 100 gives you 100 gold)

This is the code for the command. Simple & short.
Spoiler:
Code:
globals
endglobals

function cc_givegold_cmd_act takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local string src = GetEventPlayerChatString()
    local integer currentGold = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
    local string commandPart = SubString(src,0,6)
    local string goldPart = SubString(src,6,999)
    if(commandPart == "-gold ")then
        call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, currentGold + S2I(goldPart))
    endif
endfunction

function cc_givegold_cmd_init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 24
        call TriggerRegisterPlayerChatEvent(t, Player(i), "-gold ", false)
        set i = i + 1
    endloop
    call TriggerAddAction(t, function cc_givegold_cmd_act)
    set t = null
endfunction

function main takes nothing returns nothing
    call cc_givegold_cmd_init()
endfunction


thank you nuzamacuxe, i will try to make and understand what you give ^^.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO


Privacy Policy Statement
Impressum (German)