SA-MP Forums Archive
Nubbish Coding Question - 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: Nubbish Coding Question (/showthread.php?tid=369201)



Nubbish Coding Question - xSiiLenTx - 16.08.2012

Where would I put commands such at a strcmp command? what line e.g.: OnPlayerConnect()


Re: Nubbish Coding Question - doreto - 16.08.2012

for strcmp commands
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}



Re: Nubbish Coding Question - xSiiLenTx - 16.08.2012

Thanks mate! can i put more then one here?(lol)


Re: Nubbish Coding Question - Cjgogo - 16.08.2012

...of course you can,have you seen any server with only ONE command?


Re: Nubbish Coding Question - _Vortex - 16.08.2012

I would recommend using dcmd or zcmd, as it makes commands easier to add/manage.


Re: Nubbish Coding Question - Sniper Kitty - 16.08.2012

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
...of course you can,have you seen any server with only ONE command?
I've seen a server with no commands... A mini-missions server which made good use of the OnPlayerKeyStateChange callback and the OnPlayerEnterCheckpoint callback.


Re: Nubbish Coding Question - Cjgogo - 16.08.2012

Quote:
Originally Posted by Sniper Kitty
Посмотреть сообщение
I've seen a server with no commands... A mini-missions server which made good use of the OnPlayerKeyStateChange callback and the OnPlayerEnterCheckpoint callback.
Now that you mention it,I DO remeber :O(not fooling you),the controls were Numbers 2,4,6,8,that's cool,indeed.
Anyways,on-topic,indeed strcmp is unefficient and you should learn ZCMD/YCMD(they are both very good,just that YCMD is better for a server with more then 100,or 100 players,but for a server with30-50-70 players,ZCMD will do well,it's all about the proccessing time) and to make your commands more efficient use togheter with one of these system,sscanf wich is the best proccessor for commands that have the format: /command ID,rather then strtock. .And ZCMD/YCMD commands MUST not be added on OnPlayerCommandText,add them separatly at the bottom of your script .


Re: Nubbish Coding Question - xSiiLenTx - 16.08.2012

Is there any way to convert Lux Admin system/VIp etc into my gamemode.pwn? Thanks in advance


Re: Nubbish Coding Question - Weaselpwns - 16.08.2012

For more commands:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do another thing here
        return 1;
    }
    return 0;
}