carcolor script problem -
Freght - 07.07.2010
Hello guys. I have this problem.
I made a script for the colors of vehicles on command / carcolor [color] [color]. But it does not work properly. Almost always says that I must be in a vehicle, even when I'm inside the vehicle. Then, obscures other commands that are on other filterscript, saying the same thing. Can you help me?
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#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, 10)== 0)
{
new tmp[256];
new tmp2[256];
new color1 = strval(tmp);
new color2 = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
}
else
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
return 1;
}
return 0;
}
0 error.
Only two warnings: loose indentation.
Pls help me!
Re: carcolor script problem -
CAR - 07.07.2010
TOP:
pawn Код:
#include <dudb>
#pragma unused ret_memcpy
pawn Код:
if(strcmp("/carcolor", cmdtext, true, 10)== 0)
{
if(IsPlayerInVehicle(playerid))
{
new idx;
new tmp[256]; tmp = strtok(cmdtext, idx);
new tmp2[256]; tmp2 = strtok(cmdtext, idx);
new color1 = strval(tmp);
new color2 = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
}
return 1;
}
return 0;
Re: carcolor script problem -
DeathOnaStick - 07.07.2010
The brackets are very weirdly set. Are you sure you didnt cut out some when posting or you even forgot them in the script?
Edit: Sry didnt see the post before.
Re: carcolor script problem -
Freght - 07.07.2010
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\Carcolor .pwn(9
: warning 202: number of arguments does not match definition
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\Carcolor .pwn(99) : error 001: expected token: "*then", but found "{"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Why?
Re: carcolor script problem -
CAR - 07.07.2010
I made a mistake in the command, changed it. Copy it now
Re: carcolor script problem -
Freght - 07.07.2010
C:\PROGRA~1\ROCKST~1\GTASAN~1\SAMP03~1\FILTER~1\Ca rcolor.pwn(7
: warning 202: number of arguments does not match definition
C:\PROGRA~1\ROCKST~1\GTASAN~1\SAMP03~1\FILTER~1\Ca rcolor.pwn(95) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Warning
The server don't know the command
Re: carcolor script problem -
Kotomi - 07.07.2010
lol i just wanted to make a new topic because of carcolor change. luckily i saw this one here =).
Re: carcolor script problem -
CAR - 07.07.2010
pawn Код:
if(strcmp("/carcolor", cmdtext, true, 10)== 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new idx;
new tmp[256];
tmp = strtok(cmdtext, idx);
new tmp2[256]; tmp2 = strtok(cmdtext, idx);
new color1 = strval(tmp);
new color2 = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
} else {
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
}
return 1;
}
return 0;
Now fixed??
Re: carcolor script problem -
Freght - 07.07.2010
I changed IsPlayerInVehicle with IsPlayerInAnyVehicle
C:\PROGRA~1\ROCKST~1\GTASAN~1\SAMP03~1\FILTER~1\Ca rcolor.pwn(95) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
but the server don't know the command again!
Re: carcolor script problem -
Hiddos - 07.07.2010
Why use strings with a size of 256, while the max output is 128, and for the colors, I'd say using maybe strings of 4 cells max and using only one string.
On-topic:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/carcolor", cmdtext, true, 10)== 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;
}
return 0;
}
Re: carcolor script problem -
Freght - 07.07.2010
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\pacolor. pwn(81) : error 047: array sizes do not match, or destination array is too small
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\pacolor. pwn(84) : error 047: array sizes do not match, or destination array is too small
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\pacolor. pwn(8
: warning 217: loose indentation
C:\Programmi\Rockstar Games\GTA San Andreas\samp03asvr_R7_win32\filterscripts\pacolor. pwn(90) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: carcolor script problem -
Hiddos - 07.07.2010
make tmp a 128 string then, and can you show the loose identation lines?
Re: carcolor script problem -
Freght - 07.07.2010
Wow zero errors! Zero warning! But the server don't know the command again!?
What the....
Re: carcolor script problem -
Freght - 07.07.2010
zero errors with tmp a 256
Re: carcolor script problem -
The_Prince - 07.07.2010
I know this is off topic but I'm just starting to look around how to script. I'm wondering where this example template has come from, I have not seen it in the wiki is there another source for it? thanks in advance
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#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, 10)== 0)
{
new tmp[256];
new tmp2[256];
new color1 = strval(tmp);
new color2 = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
}
else
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
return 1;
}
return 0;
}
Re: carcolor script problem -
Hiddos - 07.07.2010
return 1?
Re: carcolor script problem - [L3th4l] - 07.07.2010
Why don't you use ZCMD + SSCANF? is faster
Код:
CMD:carcolor( playerid, params[ ] )
{
new Color1,Color2;
if( !IsPlayerInAnyVehicle( playerid ) ) return SendClientMessage( playerid, red, "You Must Be In A Vehicle!");
if(sscanf(params,"dd",Color1,Color2)) return SendClientMessage(playerid, red,"USAGE: /Carcolor < Color 1 > < Color 2 >");
return ChangeVehicleColor(GetPlayerVehicleID(playerid) ,Color1,Color2);
}
did not test, but im sure it works.. You will need ZCMD and SSCANF
notice how simple is to script with those two
Re: carcolor script problem -
Hiddos - 07.07.2010
Notice that some people would like an answer, not a workaround.
Re: carcolor script problem -
Kotomi - 07.07.2010
if this isnt working, could someone post a work in this kind of try. i must have a changecar system in my server which works.
Re: carcolor script problem -
Hiddos - 07.07.2010
What exactly do you mean by 'It isn't working'?
Could you show your current OnPlayerCommandText callback?