Command problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command problem (
/showthread.php?tid=458716)
Command problem -
Baumann - 18.08.2013
Hey why i get this error with this code ?
PHP код:
CMD:sc(playerid, params[])
{
new vehicle;
new ID;// wait
new Float:x,Float:y,Float:z;
if(ClassPolice == 1)return SendClientMessage(playerid, 0xffffff, "You can't use it"); //
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xffffff, "Usage: /sc [playerid]");//
vehicle = GetPlayerVehicleID(playerid);
if(GetVehicleVelocity(vehicle, x , y, z) > 50))
{
if(GetDistanceBetweenPlayers(playerid,ID) < 12)
{
new pwlvl = GetPlayerWantedLevel(playerid);
SetPlayerWantedLevel(playerid,pwlvl+1);
}
}
return 1;
}
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
warning 205: redundant code: constant expression is zero
C:\Users\janno\Desktop\UUS\gamemodes\Trucking.pwn( 172

: error 029: invalid expression, assumed zero
Re: Command problem -
Youarex - 18.08.2013
pawn Код:
if(GetVehicleVelocity(vehicle, x , y, z) > 50))
You get error because there's unmatched closing parenthesis at the end. Also that if statement won't work properly. GetVehicleVelocity function returns multiple values, the x, y and z velocities are stored in the referenced variables.
Re: Command problem -
Baumann - 18.08.2013
i have already defined vehicle which will not give you errors or multiple values & yes if(GetVehicleVelocity(vehicle, x , y, z) > 50)) will not work properly ..
Re: Command problem -
Edix - 18.08.2013
What he meant it that you have one extra ")" at the end of the "if" statement.
fix:
pawn Код:
if(GetVehicleVelocity(vehicle, x , y, z) > 50)