help with car colour -
[EDT]AmanSingh123 - 05.03.2011
hey im new to scripting and i want something that when i do /cc [id] [id] inside the game it changes your vehicles car colour could someone please help me with how i can do this?
Re: help with car colour -
austin070 - 05.03.2011
pawn Код:
if(strcmp(cmd, "/cc", true)== 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
new vid = GetPlayerVehicleID(playerid);
if(strval(result) && strval(result[2]) >126 || strval(result) && strval(result[2]) <0) return SendClientMessage(playerid, COLOR_RED, "Invalid color id!");
ChangeVehicleColor(vid, strval(result), strval(result[2]));
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
}
return 1;
}
I didn't test this, so tell me if there are any errors.
Re: help with car colour -
[EDT]AmanSingh123 - 05.03.2011
can you put that in pastebin.com please
Re: help with car colour -
austin070 - 05.03.2011
Here you go.
http://pastebin.com/0MqWzQQd
Re: help with car colour -
alpha500delta - 05.03.2011
Better do it with ZCMD and SSCANF2
pawn Код:
CMD:cc(playerid, params[])
{
new ColorID, ColorID2, vehicleid, str[75];
if(sscanf(params, "dd", ColorID,ColorID2)) return SendClientMessage(playerid, COLOR, "USAGE: /carcolor [1/126] [1/126]");
else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR, "You are not in a vehicle!");
else if(ColorID < 0 && ColorID > 126) return SendClientMessage(playerid, COLOR, "CarColor cannot be above 126 or below 0!");
else if(ColorID2 < 0 && ColorID2 > 126) return SendClientMessage(playerid, COLOR, "CarColor2 cannot be above 126 or below 0!");
else
{
vehicleid = GetPlayerVehicleID(playerid);
ChangeVehicleColor(vehicleid, ColorID, ColorID2);
format(str, sizeof(str),">> CarColor 1 changed to %d and CarColor 2 changed to %d <<",ColorID, ColorID2);
SendClientMessage(playerid, COLOR, str);
}
return 1;
}
Re: help with car colour -
austin070 - 05.03.2011
Quote:
Originally Posted by alpha500delta
Better do it with ZCMD and SSCANF2
pawn Код:
CMD:cc(playerid, params[]) { new ColorID, ColorID2, vehicleid, str[75]; if(sscanf(params, "dd", ColorID,ColorID2)) return SendClientMessage(playerid, COLOR, "USAGE: /carcolor [1/126] [1/126]"); else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR, "You are not in a vehicle!"); else if(ColorID < 0 && ColorID > 126) return SendClientMessage(playerid, COLOR, "CarColor cannot be above 126 or below 0!"); else if(ColorID2 < 0 && ColorID2 > 126) return SendClientMessage(playerid, COLOR, "CarColor2 cannot be above 126 or below 0!"); else { vehicleid = GetPlayerVehicleID(playerid); ChangeVehicleColor(vehicleid, ColorID, ColorID2); format(str, sizeof(str),">> CarColor 1 changed to %d and CarColor 2 changed to %d <<",ColorID, ColorID2); SendClientMessage(playerid, COLOR, str); } return 1; }
|
I figured a new scripter wouldn't know much of zcmd and sscanf.
Re: help with car colour -
alpha500delta - 05.03.2011
Well it's easyer... But it requires some downloading
Re: help with car colour -
[EDT]AmanSingh123 - 05.03.2011
autin i got these errors
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(542) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(544) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(544) : warning 215: expression has no effect
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(546) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(54

: error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(550) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(551) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(551) : warning 215: expression has no effect
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(553) : error 017: undefined symbol "idx"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
7 Errors.
Re: help with car colour -
Oddie - 05.03.2011
Re: help with car colour -
[EDT]AmanSingh123 - 05.03.2011
hey just wanted to say that i used autins /cc script that he put up their but when i do /cc 1 1 the car colour isnt white or /cc 3 3 its not red it only when i do /cc the car colour turns black.
sorry if im a bit annoying lol but could someone help me on that aswell?