PDA

View Full Version : How to make a Car Color command?


Toni
01/06/2010, 06:07 PM
I'm just wondering how can you make a Car Color Command? I've tried searching on the wiki/forums, not luck finding anything similar.

russo666
01/06/2010, 06:10 PM
ChangeVehicleColor(vehicleid, color 1, color 2);

?

http://wiki.sa-mp.com/wiki/Color_ID

DJDhan
01/06/2010, 06:15 PM
if(!strcmp(cmdtext,"/carcolor",true,9)==0)
{
new tmp[24],tmp2[24],Index, color1,color2;
if(!IsPlayerInAnyVehicle(playerid) return SendClientMessage(playerid,oxffffffaa,"You mst be in car to use this command");
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"Usage: /carcolor color1 color2");
tmp=strtok(cmdtext,Index);
tmp2=strtok(cmdtext,Index);

color1=strval(tmp);
color2=strval(tmp2);

ChangeVehicleColor(GetPlayerVehicleID(playerid),co lor1,color2);
return 1;
}

Toni
01/06/2010, 06:16 PM
if(!strcmp(cmdtext,"/carcolor",true,9)==0)
{
new tmp[24],tmp2[24],Index, color1,color2;

if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"Usage: /carcolor color1 color2");
color1=strtok(params,Index);
color2=strtok(params,Index);

ChangeVehicleColor(GetPlayerVehicleID(playerid),co lor1,color2);
return 1;
}





Thankyou.

DJDhan
01/06/2010, 06:18 PM
I have edited my post. Please use the code now. ;)

Toni
01/06/2010, 06:22 PM
edited out errors

DJDhan
01/06/2010, 06:25 PM
Just replace params with cmdtext. Edited again.

Toni
01/06/2010, 06:43 PM
Just replace params with cmdtext. Edited again.

Theres no errors, but when i do /carcolor 3 3 all it does is return the string "Usage: /carcolor color1 color2"

-Rebel Son-
01/06/2010, 07:31 PM
if(strcmp(cmd, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}

Toni
01/06/2010, 07:36 PM
if(strcmp(cmd, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}



thank you this works :)

-Rebel Son-
01/06/2010, 07:41 PM
Not a problem fella.

Toni
01/06/2010, 07:46 PM
Not a problem fella.

Just asking, Do you know how to make a /countdown command? :-[

-Rebel Son-
01/06/2010, 07:52 PM
Never tryed before, let me go try one, check back here soon.

EDIT

Top of script
new timer;
new secs;

The command.

if(!strcmp(cmd,"/countdown,true)) {
secs = 5;
timer = SetTimer("countdown", 999, 1);
return 1;}

the function.

forward Countdown();
public Countdown()
{
if(secs == 0)
{
GameTextForAll("~r~Go!",1000,3);
KillTimer(timer);
}
else
{
new string[8];
format(string,sizeof(string),"~R~%d",secs);
GameTextForAll(string,1000,3);
}
secs = secs-1;
return 1;
}

Toni
01/06/2010, 08:08 PM
Never tryed before, let me go try one, check back here soon.

okay

-Rebel Son-
01/06/2010, 08:11 PM
Edited my post. Go check,.

HerronInd
23/02/2011, 12:27 PM
E:\Kana.pwn(98) : error 017: undefined symbol "cmd"
E:\Kana.pwn(101) : error 017: undefined symbol "strtok"
E:\Kana.pwn(101) : error 029: invalid expression, assumed zero
E:\Kana.pwn(101) : error 017: undefined symbol "strtok"
E:\Kana.pwn(101) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

HerronInd
23/02/2011, 12:29 PM
It's my script

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}




public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/carcolor", true) == 0)
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /carcolor [color1] [color2]");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /carcolor [color1] [color2]");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (ispassenger)
Kick(playerid);
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}



public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

HerronInd
23/02/2011, 12:31 PM
Please Help :/

HyperZ
23/02/2011, 12:34 PM
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], idx;
if(strcmp(cmd, "/carcolor", true) == 0)
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
return 0;
}
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

HerronInd
23/02/2011, 12:42 PM
can you give me command which will change vehcle color in eversecond?

:o

and thanks for
/carcolor command it's working fine :)

[EDT]AmanSingh123
06/03/2011, 11:11 AM
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(531) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(531) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(532) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(533) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(534) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(534) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(535) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(536) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


8 Errors.

SA_Claude
30/08/2011, 03:45 AM
if(strcmp(cmd, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}

E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1050) : error 017: undefined symbol "cmd"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1054) : error 017: undefined symbol "tmp"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1054) : error 017: undefined symbol "idx"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1055) : error 017: undefined symbol "tmp"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1056) : error 017: undefined symbol "tmp"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1057) : error 017: undefined symbol "tmp"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1057) : error 017: undefined symbol "idx"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1058) : error 017: undefined symbol "tmp"
E:\R5 0.3c Server\gamemodes\SevenStar.pwn(1059) : error 017: undefined symbol "tmp"


HELP ME

SA_Claude
30/08/2011, 03:48 AM
AmanSingh123;1104126']C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(531) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(531) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(532) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(533) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(534) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(534) : error 017: undefined symbol "strtok"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(535) : error 017: undefined symbol "tmp"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(536) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


8 Errors.


new cmd[256], tmp[256], idx;

Add this in OnPlayerCommandsText

martin3644
23/08/2012, 01:10 AM
if(strcmp(cmd, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}

I have these errors with this.

C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6178) : error 017: undefined symbol "cmd"
C:\Documents and Settings\userDesktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6182) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6182) : error 017: undefined symbol "idx"
C:\Documents and Settings\user/Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6183) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6184) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6185) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6185) : error 017: undefined symbol "idx"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6186) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\CrazyDrifting SA-MP 0.3e\gamemodes\Crazy-Drifting.pwn(6187) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


9 Errors.

martin3644
18/12/2012, 10:03 PM
if(strcmp(cmd, "/carcolor", true) == 0){
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /carcolor >color1< >color2<");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in any Vehicle!");
}
return 1;}

Doesnt work by me. It returns to the string USAGE: /cc (color1) (color2)


Please help!?

GokuSsj
05/01/2014, 07:00 AM
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_ANALOG_LEFT && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new colors = random(sizeof(CarColors));
new colors2 = random(sizeof(CarColors2));
ChangeVehicleColor(vid,CarColors[colors][0],CarColors2[colors2][0]);
RepairVehicle(GetPlayerVehicleID(playerid));
SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
}
}
}

new CarColors[][1] =
{
{1},
{2},
{3}
.......................... till {126}
new CarColors[][2] =
{
{126}
{125}
............................till {1}

and when u will press num 4 car color will change :D

K9IsGodly
05/01/2014, 07:02 AM
How would you make a command like this via ZCMD?

GokuSsj
05/01/2014, 07:07 AM
CMD:carcolour(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be the driver of the vehicle to use this command");
new color1, color2;
new vehicleid = GetPlayerVehicleID(playerid);
if(sscanf(params, "hh", color1, color2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /carcolour [colour1] [colour2]");
ChangeVehicleColor(vehicleid, color1, color2);
GameTextForPlayer(playerid, "~r~you have changed your ~g~car~b~ colours", 2000, 5);
return 1;
}

Ryan_Bowe
05/01/2014, 07:08 AM
....

GokuSsj
05/01/2014, 07:12 AM
Please add reputation if i help you :P

jameskoonk
29/11/2014, 06:23 PM
where i can put this code.

thank you .