[HELP] Object Command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Object Command (
/showthread.php?tid=361005)
[HELP] Object Command -
kbalor - 19.07.2012
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.
Re: [HELP] Object Command -
nepstep - 19.07.2012
So something like that?
pawn Код:
#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,listitem,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;
}
Re: [HELP] Object Command -
kbalor - 19.07.2012
Quote:
Originally Posted by nepstep
So something like that?
pawn Код:
#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,listitem,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?