SA-MP Forums Archive
automatic cmd? - 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: automatic cmd? (/showthread.php?tid=398165)



automatic cmd? - Pro_Scriptor - 08.12.2012

how to make an automatic cmd like when a player connects execute command from him /login


Re: automatic cmd? - Dolby - 08.12.2012

Zcmd:
pawn Код:
cmd_login(playerid,"");



Re: automatic cmd? - Lordzy - 08.12.2012

I didn't understand what you asked really. I hope it might be kinda this:
You can use the callback "OnPlayerConnect" which gets called when a player get connected.
pawn Код:
public OnPlayerConnect(playerid)
{
  //Your code here.
 return 1;
}
.


Re: automatic cmd? - Pro_Scriptor - 08.12.2012

@ LordZ i know that but code should that be?


Re: automatic cmd? - Pro_Scriptor - 08.12.2012

i will rep


Re: automatic cmd? - Lordzy - 08.12.2012

I'm sorry, I can't understand what you're saying. :/


Re: automatic cmd? - Threshold - 08.12.2012

He wants to know how to execute a command when a player connects. It's not that hard to understand...

If you're using something like ZCMD, you need to do this:
pawn Код:
public OnPlayerConnect(playerid)
{
    cmd_login(playerid, "");
    return 1;
}
Otherwise, you can just copy and paste code from the command.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/login", true) == 0)
    {
        mycodehere1;
        mycodehere2;
        mycodehere3;
    }
    return 0;
}
You need to copy and paste that into your OnPlayerConnect. (NOT CUT!)

pawn Код:
OnPlayerConnect(playerid)
{
    mycodehere1;
    mycodehere2;
    mycodehere3;
    return 1;
} //mycodehere is just for example, not actual functioning code.