Re: carcolor script problem -
Freght - 07.07.2010
well, ehm...when i type /carcolor color color , the server say UNKNOWN COMMAND, but the script hasn't errors or warnings. why?
Re: carcolor script problem -
Freght - 07.07.2010
l3thal, which include files, I have set for this script?
i must add this in the commandtext callback?
Re: carcolor script problem -
Hiddos - 07.07.2010
I possible got it:
[pawn]if(strcmp("/carcolor", cmdtext, true, 10)== 0)[/pawn[
Notice that "10"? It checks if that's the string length. Just remove it.
Replace it by:
pawn Код:
if(strcmp("/carcolor", cmdtext, true)== 0)
So you'll get:
pawn Код:
if(strcmp("/carcolor", cmdtext, true)== 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
new tmp[4];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
new color1 = strval(tmp);
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
new color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
Tip for saving time:
pawn Код:
if(strcmp(cmdtext,"/bla",true) == 0)
Checks if it compares.
pawn Код:
if(!strcmp(cmdtext,"/bla",true))
Does the same.
Re: carcolor script problem -
Freght - 07.07.2010
Now the script goes, but puts the wrong colors! omg
Re: carcolor script problem -
Freght - 07.07.2010
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <dudb>
#pragma unused ret_memcpy
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BRIGHTRED 0xFF0000AA
#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 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("/carcolor", cmdtext, true))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
new idx;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
new color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
new color2 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
return 0;
}
ok now change one of the two colors very well, the other puts the black!
Re: carcolor script problem -
Freght - 07.07.2010
why the second color doesn't change
Re: carcolor script problem -
Toni - 07.07.2010
Not that hard. this code works (I used/tested in my own server.)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/carcolor", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Your Not in any Vehicle!");
}
return 1;
}
return 0;
}
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;
}
and if you can't even get that right, heres the actual file!
Re: carcolor script problem - [L3th4l] - 07.07.2010
@ Freght:
If you still want those includes, download ZCMD include, use search.
And you will also need SSCANF by Y_Less(you add that at the bottom of your script or make it an include, wtever. use search)
and the command, you don't put in under OnPlayerCommandText
just about anywere
Re: carcolor script problem -
Freght - 08.07.2010
thank you guys for the help
Re: carcolor script problem -
Toni - 08.07.2010
Quote:
Originally Posted by Freght
thank you guys for the help
|
No Problem.