There is no errors in this script, but it's not working InGame. [Fixed] -
Kethrios - 19.11.2012
Hello guys,
Since days I'm looking for a way to get some sirens on undercover cop cars.
When I saw that in fact I already had one in my script, the command is /gyro. But the siren does not appear, not even for a second.
Can you guys help me finding out what the problem is here ? It is suppose to work like a charm ^^
Here is my code :
pawn Код:
else if(strcmp(subcmd, "gyrophare", true) == 0 || strcmp(subcmd, "gyro", true) == 0)
{
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
if(PlayerInfo[playerid][pRank] < 4)
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Il vous faut le rang 4 minimum pour cette commande."); return 1;}
if(!OnDuty[playerid])
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous devez кtre en service."); return 1;}
if(!IsPlayerInAnyVehicle(playerid) || (model != 405 && model != 475 && model != 540 && model != 506 && model != 589 && model != 560 && model != 431 && model != 413 && model != 459 && model != 602 && model != 415 && model != 507 && model != 451 && model != 525))
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Ces vйhicules ne sont pas compatibles."); return 1;}
if(car_sirene[vehicleid] == 0 && car_sirene2[vehicleid] == 0)
{
format(proxy_msg, sizeof(proxy_msg), "%s active le gyrophare de son vйhicule.", playername);
car_sirene[vehicleid] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
car_sirene2[vehicleid] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
if(model == 405) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, -0.300000, -0.100000, 0.790000, 0.000000, 0.000000, 0.000000);
else if(model == 475 || model == 540) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, -0.375000, -0.225000, 0.764999, 0.000000, 0.000000, 0.000000);
else if(model == 506) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, -0.400000, -0.500000, 0.620000, 0.000000, 0.000000, 0.000000);
else if(model == 589) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, -0.400000, -0.300000, 1.120000, 0.000000, 0.000000, 0.000000);
else if(model == 560) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.300000, 0.824999,0.375000, -0.000005, 0.000000, 0.000000);
else if(model == 413) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.000000, 1.605000, 0.485000, 0.000000, 0.000000, 0.000000);
else if(model == 459) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.000000, 1.500000, 0.495000, 0.000000, 0.000000, 0.000000);
else if(model == 602) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, -0.509999, -0.225000, 0.749999, 0.000000, 0.000000, 0.000000);
else if(model == 415) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.020000, 0.654999, 0.185000, 0.000000, 0.000000, 0.000000);
else if(model == 507) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.300000, 0.804999, 0.365000, 0.000000, 0.000000, 0.000000);
else if(model == 451) AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.449999, 0.524999, 0.164999, 0.000000, 0.000000, 0.000000);
else if(model == 431)
{
AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.000000, -3.975001, 2.300000, 0.000000, 0.000000, 0.000000);
AttachObjectToVehicle(car_sirene2[vehicleid], vehicleid, -0.010000, 3.975001, 2.240000, 0.000000, 0.000000, 0.000000);
}
else if(model == 525)
{
AttachObjectToVehicle(car_sirene[vehicleid], vehicleid, 0.599999, -0.469999, 1.435000, 0.000000, 0.000000, 0.000000);
AttachObjectToVehicle(car_sirene2[vehicleid], vehicleid, -0.599999,-0.469999,1.400000,0.000000,0.000000,0.000000);
}
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous avez mit la sirene civil.");
}
else
{
format(proxy_msg, sizeof(proxy_msg), "%s йteint le gyrophare de son vйhicule.", playername);
DestroyObject(car_sirene[vehicleid]);
car_sirene[vehicleid] = 0;
DestroyObject(car_sirene2[vehicleid]);
car_sirene2[vehicleid] = 0;
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous enlevez le gyrophare de votre vйhicule.");
}
proxy_sendMsg(playerid, proxy_msg);
return 1;
}
Re : There is no errors in this script, but it's not working InGame. -
Kethrios - 19.11.2012
Hehe thank you for telling me this.
How can I know what is wrong in it ? I'm a beginner, I've no idea, for me it looks right.
Re: There is no errors in this script, but it's not working InGame. -
Konstantinos - 19.11.2012
Debug everything! Then, you can easily found from where the mistake/wrong piece of code come from and try to fix it.
Re : There is no errors in this script, but it's not working InGame. -
Kethrios - 19.11.2012
How do I debug ? ._.
Re: There is no errors in this script, but it's not working InGame. -
Konstantinos - 19.11.2012
An example:
pawn Код:
main( )
{
new
a = 20,
b = 21,
c
;
if( a > b ) c = a + b;
if( a < b ) c = a - b;
}
Let's say that something is wrong with that code. You can use print/printf to check if it is called and which are the results.
pawn Код:
// An example of it
main( )
{
new
a = 20,
b = 21,
c
;
printf( "a = %d\nb = %d", a, b );
if( a > b )
{
printf( "if( %d > %d ) is true!", a, b );
c = a + b;
printf( "c is now %d", c );
}
if( a < b )
{
printf( "if( %d < %d ) is true!", a, b );
c = a + b;
printf( "c is now %d", c );
}
}
Re : There is no errors in this script, but it's not working InGame. -
Kethrios - 19.11.2012
Alright I try this when I'll get back home.
For now, I've modified my code, and I've now this :
pawn Код:
else if(strcmp(subcmd, "gyrophare", true) == 0 || strcmp(subcmd, "gyro", true) == 0)
{
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
if(PlayerInfo[playerid][pRank] < 4)
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Il vous faut le rang 4 minimum pour cette commande."); return 1;}
if(!OnDuty[playerid])
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous devez кtre en service."); return 1;}
if(!IsPlayerInAnyVehicle(playerid) || (model != 405 && model != 475 && model != 540 && model != 506 && model != 589 && model != 560 && model != 431 && model != 413 && model != 459 && model != 602 && model != 415 && model != 507 && model != 451 && model != 525))
{SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Ces vйhicules ne sont pas compatibles."); return 1;}
if(car_sirene[vehicleid] == 0 && car_sirene2[vehicleid] == 0)
{
if(car_sirene[GetPlayerVehicleID(playerid)] == 0 && car_sirene2[GetPlayerVehicleID(playerid)] == 0)
{
car_sirene2[GetPlayerVehicleID(playerid)] = CreateObject(18646,0,0,0,0,0,0,100);
AttachObjectToVehicle(car_sirene[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),-0.5,0.0,0.85,0,0,0);//Sirene auf dem Dach, Messung Sultan
car_sirene2[GetPlayerVehicleID(playerid)] = 1;
return 1;
}
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous avez mit la sirene civil.");
return 1;
}
{
format(proxy_msg, sizeof(proxy_msg), "%s йteint le gyrophare de son vйhicule.", playername);
DestroyObject(car_sirene[vehicleid]);
car_sirene[vehicleid] = 0;
DestroyObject(car_sirene2[vehicleid]);
car_sirene2[vehicleid] = 0;
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous enlevez le gyrophare de votre vйhicule.");
return 1;
}
}
proxy_sendMsg(playerid, proxy_msg);
return 1;
}
}
But I have these warnings :
Код:
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\usrp.pwn(20753) : warning 217: loose indentation
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\usrp.pwn(20759) : warning 225: unreachable code
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\usrp.pwn(20759) : warning 217: loose indentation
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\usrp.pwn(20770) : warning 225: unreachable code
What can I do ?
Re: There is no errors in this script, but it's not working InGame. -
Konstantinos - 19.11.2012
pawn Код:
// loose indentation
main()
{
new a;
new b; // it looses indentation
new c;
new d; // it looses indentation
}
pawn Код:
CMD:test( playerid, params[ ] )
{
return print( "The next line will give us warning as unreachable code!" );
return 1;
}
pawn Код:
CMD:test2( playerid, params[ ] )
{
print( "Look 2 lines down" );
return 1;
return print( "The above line will give us warning as unreachable code!" );
}
Re : There is no errors in this script, but it's not working InGame. -
Kethrios - 19.11.2012
Ok so this is the code I have right now :
pawn Код:
if(strcmp(subcmd, "gyrophare", true) == 1 || strcmp(subcmd, "gyro", true) == 1)
{
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
if(PlayerInfo[playerid][pRank] < 4)
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Il vous faut le rang 4 minimum pour cette commande.");
return 1;
}
if(!OnDuty[playerid])
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous devez кtre en service.");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid) || (model != 405 && model != 475 && model != 540 && model != 506 && model != 589 && model != 560 && model != 431 && model != 413 && model != 459 && model != 602 && model != 415 && model != 507 && model != 451 && model != 525))
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Ces vйhicules ne sont pas compatibles.");
return 1;
}
if(car_sirene[vehicleid] == 1 && car_sirene2[vehicleid] == 1)
{
if(car_sirene[GetPlayerVehicleID(playerid)] == 0 && car_sirene2[GetPlayerVehicleID(playerid)] == 0)
{
car_sirene2[GetPlayerVehicleID(playerid)] = CreateObject(18646,0,0,0,0,0,0,100);
AttachObjectToVehicle(car_sirene[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),-0.5,0.0,0.85,0,0,0);
car_sirene2[GetPlayerVehicleID(playerid)] = 1;
return 1;
}
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous avez mit la sirene civil.");
}
{
format(proxy_msg, sizeof(proxy_msg), "%s йteint le gyrophare de son vйhicule.", playername);
proxy_sendMsg(playerid, proxy_msg);
DestroyObject(car_sirene[vehicleid]);
car_sirene[vehicleid] = 0;
DestroyObject(car_sirene2[vehicleid]);
car_sirene2[vehicleid] = 0;
{
SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous enlevez le gyrophare de votre vйhicule.");
return 1;
}
}
}
}
I have NO ERRORS.
But when I use /p gyro ingame. First try : No siren, no fail message. Second try : No siren, fail message
And at the 2nd try I get this too : "[POLICE] Invalid action."
Can someone help me to figure out what the problem is ?
Re : There is no errors in this script, but it's not working InGame. -
Kethrios - 19.11.2012
I fixed the problem by using an other code.
Thanks for helping me Dwane and ******.
Re: There is no errors in this script, but it's not working InGame. -
zero4000 - 19.11.2012
People who have been telling you your coding is wrong is possibly full of bullshit. Try this, Add the FS your trying to get to work ingame to the first FS loaded in your config file. Like this
filterscripts (add name here first) (then the rest of your FS)
If it now works in game then you are having the same trouble I am:
https://sampforum.blast.hk/showthread.php?tid=393802
If it still doesnt work in game then you need to debug it and follow what others are telling you! Do not mess with the coding until you see if it will load correctly with no other FS before it!