Jump to content
  • 0

help using addrid on script


Question

Posted
-	script	trial	-1,{
OnInit:
	bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	addrid(1);
	end;
}

 

Is this correct? I want to make @test command by using "addrid" to give items to all players within the map, server,guild,party, just like @itemmap.

Anyone help me with this one? 

16 answers to this question

Recommended Posts

Posted

It's better to check if the item id exist and if the amount > 0

also about getitem the values must be integer values

A sample

-    script    trial    -1,{
OnInit:
    bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
    end;
OnAtcommand:
    if ( .@atcmd_numparameters != 2 ) {
        message .@myname$, "Usage: "+ .@atcmd_command$ +" <item id> <amount>";
        end;
    }
    .atoi_id = atoi( .@atcmd_parameters$[0] );
    .atoi_amount = atoi( .@atcmd_parameters$[1] );
    .@myname$ = strcharinfo(0);
    if ( getiteminfo( .atoi_id,0 ) == -1 ) {
        message .@myname$, "Requesting to send an non-existing item ("+ .atoi_id +"). "+ .@atcmd_command$ +" failed.";
        end;
    }
    else if ( .atoi_amount < 1 ) {
        message .@myname$, "You can't send "+ .atoi_amount +" item. "+ .@atcmd_command$ +" failed.";
        end;
    }
    addrid(1);
    getitem .atoi_id, .atoi_amount;
    end;
}


getiteminfo + atoi

 

EDIT : fix an error

Posted


-    script    trial    -1,{

OnInit:

    bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";

    end;

OnAtcommand:

    addrid(1);

    getitem <id>,<amount>;

end;

}

Posted
-    script    trial    -1,{
OnInit:
    bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
    end;
OnAtcommand:
    addrid(1);
    getitem <id>,<amount>;
    end;
}

xmr3bc.png

 

I don't know what to put in line 7. the "<" What should I put sir? :)

Posted

 

>>it should be like this 

 

getitem 501,100

 

it gives 100pcs Apple's on all the players on the map

 

So meaning @test is just for only specific items? I cannot make it in game like:

@test 607 1

@test 671 1

 

If you want it that way, you can try this : 

// @test <item id> <amount>
-    script    trial    -1,{
OnInit:
        bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
        end;
OnAtcommand:
        if ( .@atcmd_numparameters != 2 ) end;
        addrid(1);
        getitem .@atcmd_parameters$[0], .@atcmd_parameters$[1];
        end;
}
Posted
-    script    trial    -1,{
OnInit:
    bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
    end;
OnAtcommand:
    if ( .@atcmd_numparameters != 2 ) {
        message .@myname$, "Usage: "+ .@atcmd_command$ +" <item id> <amount>";
        end;
    }
    .atoi_id = atoi( .@atcmd_parameters$[0] );
    .atoi_amount = atoi( .@atcmd_parameters$[1] );
    .@myname$ = strcharinfo(0);
    if ( getiteminfo( .atoi_id,0 ) == -1 ) {
        message .@myname$, "Requesting to send an non-existing item ("+ .atoi_id +"). "+ .@atcmd_command$ +" failed.";
        end;
    }
    else if ( .atoi_amount < 1 ) {
        message .@myname$, "You can't send "+ .atoi_amount +" item. "+ .@atcmd_command$ +" failed.";
        end;
    }
    addrid(1);
    getitem .atoi_id, .atoi_amount;
    end;
}

@sir Capuche, can you please put a getgmlevel command? 

Posted

or

*bindatcmd "command","<NPC object name>::<event label>"{,<atcommand level>,<charcommand level>};

bindatcmd "test",strnpcinfo(3)+"::OnAtcommand",60,60;

 

Excuse me Capuche, i tried to use the script but i have a question.. why is it that when i tried to use it again? its not working anymore.. just once?

Posted

Try the final version. Check if you have any error on your mapserv.

-	script	trial	-1,{
OnInit:
	bindatcmd "test",strnpcinfo(3)+"::OnAtcommand",60,60;
	end;
OnAtcommand:
	if ( .@atcmd_numparameters != 2 ) {
		message .@myname$, "Usage: "+ .@atcmd_command$ +" <item id> <amount>";
		end;
	}
	.atoi_id = atoi( .@atcmd_parameters$[0] );
	.atoi_amount = atoi( .@atcmd_parameters$[1] );
	.@myname$ = strcharinfo(0);
	if ( getiteminfo( .atoi_id,0 ) == -1 ) {
		message .@myname$, "Requesting to send an non-existing item ("+ .atoi_id +"). "+ .@atcmd_command$ +" failed.";
		end;
	}
	else if ( .atoi_amount < 1 ) {
		message .@myname$, "You can't send "+ .atoi_amount +" item. "+ .@atcmd_command$ +" failed.";
		end;
	}
	addrid(1);
	getitem .atoi_id, .atoi_amount;
	end;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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