Car Colour Changing - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car Colour Changing (
/showthread.php?tid=71339)
Car Colour Changing -
Abyss - 31.03.2009
How would i go about making a command that changes the colour of your car? Like /colour <First Colour> <Second Colour>
Re: Car Colour Changing -
Sandra18[NL] - 31.03.2009
https://sampwiki.blast.hk/wiki/ChangeVehicleColor
Wiki is your friend!
Re: Car Colour Changing -
Abyss - 31.03.2009
I don't mean that. I mean the player using the command can choose what the two colours should be.
Re: Car Colour Changing -
Sandra18[NL] - 31.03.2009
If you don't have already, put the strtok-function in your gamemode. (You can find that function in lvdm.pwn which came with serverdownload).
Put (if you don't have already) at the top of your OnPlayerCommandText-callback:
Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
and then your command will be:
Код:
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;
}
Re: Car Colour Changing -
LarzI - 31.03.2009
Sandra, you should know that you shouldn't use 256 as string variable size...
Re: Car Colour Changing -
Danut - 31.03.2009
yea , because you can't write 67 figures
Re: Car Colour Changing -
Abyss - 31.03.2009
Thank you very much
Re: Car Colour Changing -
LarzI - 31.03.2009
Quote:
Originally Posted by MoroJr™
yea , because you can't write 67 figures
|
huh?
Re: Car Colour Changing -
Sandra18[NL] - 31.03.2009
Quote:
Originally Posted by lrZ^ aka LarzI
Sandra, you should know that you shouldn't use 256 as string variable size... 
|
Making stringvariable size less then 255, you will get "array sizes do not match, or destination array is too small"-error with strtok
Re: Car Colour Changing -
Nero_3D - 31.03.2009
Quote:
Originally Posted by =>Sandra<=
Quote:
Originally Posted by lrZ^ aka LarzI
Sandra, you should know that you shouldn't use 256 as string variable size... 
|
Making stringvariable size less then 255, you will get "array sizes do not match, or destination array is too small"-error with strtok 
|
only if you use some kinds of noob modifications of strtok
thats the orginal from pawn-lang.pdf (2006)
pawn Код:
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
}