"/car" help | need some direction - 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: "/car" help | need some direction (
/showthread.php?tid=361997)
"/car" help | need some direction -
darkvsoul36 - 23.07.2012
Hi, I was looking through a few scripts I had on my computer and I don't understand what the following means entirely.
Код:
if(IsPlayerConnected(playerid))
{
new x_v[256];
x_v = strtok(cmdtext, idx);
if(!strlen(x_v))
{
SendClientMessage(playerid, COLOR_WHITE, "Server: /car [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: engine, hood, trunk, lights");
return 1;
}
I understand that it checks if the player is connected and it will send them a message, but I don't understand
Код:
new x_v[256];
x_v = strtok(cmdtext, idx);
if(!strlen(x_v))
Could someone provide some assistance please for a push in the right direction? Much appreciated.
Re: "/car" help | need some direction -
Kindred - 23.07.2012
x_v is simply a string that has a 256 string size. Now, strtok is used to find what is typed AFTER a space, so this code simply states that if the player does not type in anything after a space (or does not type a space) it will sow the message.
EDIT: More on strtok can be found
HERE
EDIT2: Forgot about the strlen part, strlen is used to get the length of the string, so lets say the string is test, the length is 4. Now, what it is checking is if there is no size, meaning it is 0, and so it will show the message.
Re: "/car" help | need some direction -
darkvsoul36 - 23.07.2012
Thank you! This has been a great help considering how I haven't been able to get a clear answer. This has really helped me understand this section of the script.