31.03.2009, 18:40
How would i go about making a command that changes the colour of your car? Like /colour <First Colour> <Second Colour>
new cmd[256], idx; cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/carcolor", true)==0)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, 0xFF0000AA, "You can only use this command while driving a vehicle!");
return 1;
}
new tmp1[256], tmp2[256];
tmp1= strtok(cmdtext, idx);
tmp2= strtok(cmdtext, idx);
if(!strlen(tmp1) || !strlen(tmp2))
{
SendClientMessage(playerid, 0xFF0000AA, "Use: /carcolor [color1] [color2]");
return 1;
}
new color1 = strval(tmp1);
new color2 = strval(tmp2);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
|
Originally Posted by MoroJr™
yea , because you can't write 67 figures
|
|
Originally Posted by lrZ^ aka LarzI
Sandra, you should know that you shouldn't use 256 as string variable size...
![]() |
|
Originally Posted by =>Sandra<=
Quote:
![]() |
strtok(const string[], &index)
{
new length = strlen(string)
/* skip leading white space */
while (index < length && string[index] <= ' ')
index++
/* store the word letter for letter */
new offset = index /* save start position of token */
new result[20] /* string to store the word in */
while (index < length && string[index] > ' ' && index - offset < sizeof result - 1)
{
result[index - offset] = string[index]
index++
}
result[index - offset] = EOS /* zero-terminate the string */
return result
}