Help with this command [+1 rep] -
sniperwars - 15.03.2012
Hi guys,
I have just scripted two commands to save and load saved positions.
I have a slight problem with the /loadp command:
pawn Код:
if(strcmp(cmdtext, "/loadp", true, 10) == 0)
{
if(!floatsqroot(PosX[playerid]+PosY[playerid]+PosZ[playerid]))
{
return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Please use /savep first!");
}
else
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), PosX[playerid], PosY[playerid], PosZ[playerid]);
SetVehicleZAngle(GetPlayerVehicleID(playerid), PosA[playerid]);
SetCameraBehindPlayer(playerid);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), PosI[playerid]);
}
else
{
InCar[playerid] = false;
SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
SetPlayerFacingAngle(playerid, PosA[playerid]);
SetCameraBehindPlayer(playerid);
}
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
SetPlayerInterior(playerid, PosI[playerid]);
SendClientMessage(playerid, COLOR_GREEN, "Saved position has been successfully loaded.");
}
return 1;
}
I have also put this on top of my script:
pawn Код:
new Float: PosX[MAX_PLAYERS], Float: PosY[MAX_PLAYERS], Float: PosZ[MAX_PLAYERS], Float: PosA[MAX_PLAYERS], PosI[MAX_PLAYERS];
When I compile my gamemode, I get these errors:
Код:
error 017: undefined symbol "InCar"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
This is the line that I get the error on:
Hope someone can help.
Re: Help with this command [+1 rep] -
HighPitchedVoice - 15.03.2012
pawn Код:
if(!strcmp(cmdtext, "/loadp", true, 10) == 0)
{
if(!floatsqroot(PosX[playerid]+PosY[playerid]+PosZ[playerid])
{
return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Please use /savep first!");
}
else
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), PosX[playerid], PosY[playerid], PosZ[playerid]);
SetVehicleZAngle(GetPlayerVehicleID(playerid), PosA[playerid]);
SetCameraBehindPlayer(playerid);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), PosI[playerid]);
}
else
{
InCar(playerid) = false;
SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
SetPlayerFacingAngle(playerid, PosA[playerid]);
SetCameraBehindPlayer(playerid);
}
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
SetPlayerInterior(playerid, PosI[playerid]);
SendClientMessage(playerid, COLOR_GREEN, "Saved position has been successfully loaded.");
}
return 1;
}
Should be working there.
Re: Help with this command [+1 rep] -
nmader - 15.03.2012
Should be:
pawn Код:
IsPlayerInAnyVehicle(playerid) == false;
Re: Help with this command [+1 rep] -
sniperwars - 15.03.2012
I get two warnings now:
Код:
warning 213: tag mismatch
warning 215: expression has no effect
Line:
pawn Код:
IsPlayerInAnyVehicle(playerid) == false;
Re: Help with this command [+1 rep] -
eesh - 15.03.2012
pawn Код:
if(!strcmp(cmdtext, "/loadp", true, 10) == 0)
{
if(!floatsqroot(PosX[playerid]+PosY[playerid]+PosZ[playerid]))
{
return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Please use /savep first!");
}
else
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), PosX[playerid], PosY[playerid], PosZ[playerid]);
SetVehicleZAngle(GetPlayerVehicleID(playerid), PosA[playerid]);
SetCameraBehindPlayer(playerid);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), PosI[playerid]);
}
else
{
InCar[playerid]=false;
SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
SetPlayerFacingAngle(playerid, PosA[playerid]);
SetCameraBehindPlayer(playerid);
}
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
SetPlayerInterior(playerid, PosI[playerid]);
SendClientMessage(playerid, COLOR_GREEN, "Saved position has been successfully loaded.");
}
return 1;
}
on top:
pawn Код:
new Float: PosX[MAX_PLAYERS], Float: PosY[MAX_PLAYERS], Float: PosZ[MAX_PLAYERS], Float: PosA[MAX_PLAYERS], PosI[MAX_PLAYERS], bool:InCar[MAX_PLAYERS];
Re: Help with this command [+1 rep] -
nmader - 15.03.2012
perhaps it should only be one = instead of ==, my mistake if that is the situation
Re: Help with this command [+1 rep] -
ReneG - 15.03.2012
Read
Control Structures.
= assigns a value
== compares a value (used in if and else statements)
pawn Код:
/* This declares a new variable and sets it to 5 using one = sign */
new a;
a = 5;
pawn Код:
/* This declares a new variable, sets it to 5, and if a is equal to 5 then it prints the message */
new a;
a = 5;
if(a == 5)
{
print("Yay, a is equal to 5.");
return 1;
}
I hope you were able to differentiate the two. @nmader I suggest you gain a little bit more knowledge before helping here.
Re: Help with this command [+1 rep] -
sniperwars - 15.03.2012
So what is the solution then ?
Can you edit the command above ?
Re: Help with this command [+1 rep] -
Ronaldo_raul™ - 15.03.2012
I re-made the whole script ( Including command /savep ).
Try this -
pawn Код:
new Float: x , Float: y , Float: z , Float: Angle;
CMD:savep( playerid , params [] )
{
GetPlayerPos ( playerid , x , y , z ) ;
GetPlayerFacingAngle ( playerid , Angle ) ;
return 1;
}
CMD:loadp( playerid , params [] )
{
if(x == 0.0 && y == 0.0 && z == 0.0)
{
SendClientMessage(playerid, -1, "* Write /savep before teleporting.");
}
else
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
SetVehiclePos(VehicleID, x , y , z);
SetPlayerFacingAngle(playerid,Angle);
SetCameraBehindPlayer(playerid);
LinkVehicleToInterior(GetPlayerVehicleID(playerid),PosI[playerid]);
}
else
{
SetPlayerPos(playerid,x, ,y , z);
SetPlayerFacingAngle(playerid,Angle);
SetCameraBehindPlayer(playerid);
}
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
SetPlayerInterior(playerid, PosI[playerid]);
SendClientMessage(playerid, -1, "* You has been teleporting to saved position.");
}
return 1;
}
Re: Help with this command [+1 rep] -
sniperwars - 15.03.2012
Can you convert that too STRCMP please ?