PDA

View Full Version : [HELP] Object Command


kbalor
19/07/2012, 05:56 PM
Anyone mind helping me to make a simple command using DIALOG STYLE LIST.

I have here a Body object SetPlayerAttachedObject( playerid, 0, 18645, 2, 0.050000, 0.019999, 0.000000, 100.000000, 100.000000, 0.000000, 1.000000, 1.000000, 1.000000 ); // MotorcycleHelmet1 - helmet

Here is what i want:
If player do /helm. The object above will show and attached to a player. Also add Remove Object in the list. Remove Object will obviously remove object that is attach to a player.

nepstep
19/07/2012, 06:36 PM
So something like that? :D

#include <a_samp>
#define HELM_DIALOG 123456
//define the dialog ID here so it won't inflict with other dialogs on your gamemode.


public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/helm", true)) //Using strcmp because i don't know your command processor, should be avoided anyway.
{
ShowPlayerDialog(playerid,HELM_DIALOG,DIALOG_STYLE _LIST,"Helmet Dialog","Attach Helmet\nDetach Helmet","Okay","Close"); //showing dialog.
return 1;
}
return 0;
}
public OnDialogResponse(playerid,dialogid,response,listit em,inputtext[])
{
if(dialogid == HELM_DIALOG)
{
if(response)
{
if ( listitem == 0)//List option 1(Attach Helmet)
{
SetPlayerAttachedObject( playerid, 0, 18645, 2, 0.050000, 0.019999, 0.000000, 100.000000, 100.000000, 0.000000, 1.000000, 1.000000, 1.000000 ); //attaching the object.
SendClientMessage(playerid,-1,"{FF0000}You have successfully attached your helmet!");//just sending an informational message.
return 1;
}
if ( listitem == 1)//List option 2(Detach Helmet)
{
RemovePlayerAttachedObject(playerid, 0); //detaching the object.
SendClientMessage(playerid,-1,"{FF0000}You have successfully detached your helmet!");//just sending an informational message.
return 1;
}
}
}
return 1;
}

kbalor
19/07/2012, 07:54 PM
So something like that? :D

#include <a_samp>
#define HELM_DIALOG 123456
//define the dialog ID here so it won't inflict with other dialogs on your gamemode.


public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/helm", true)) //Using strcmp because i don't know your command processor, should be avoided anyway.
{
ShowPlayerDialog(playerid,HELM_DIALOG,DIALOG_STYLE _LIST,"Helmet Dialog","Attach Helmet\nDetach Helmet","Okay","Close"); //showing dialog.
return 1;
}
return 0;
}
public OnDialogResponse(playerid,dialogid,response,listit em,inputtext[])
{
if(dialogid == HELM_DIALOG)
{
if(response)
{
if ( listitem == 0)//List option 1(Attach Helmet)
{
SetPlayerAttachedObject( playerid, 0, 18645, 2, 0.050000, 0.019999, 0.000000, 100.000000, 100.000000, 0.000000, 1.000000, 1.000000, 1.000000 ); //attaching the object.
SendClientMessage(playerid,-1,"{FF0000}You have successfully attached your helmet!");//just sending an informational message.
return 1;
}
if ( listitem == 1)//List option 2(Detach Helmet)
{
RemovePlayerAttachedObject(playerid, 0); //detaching the object.
SendClientMessage(playerid,-1,"{FF0000}You have successfully detached your helmet!");//just sending an informational message.
return 1;
}
}
}
return 1;
}


Thanks man + rep but my problem is when i attach object and i change skin, it misaligned. i think it is because of the offset. anything know about this?