Problem with garage system - 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: Problem with garage system (
/showthread.php?tid=334956)
Problem with garage system -
vvhy - 16.04.2012
Having trouble with this, it works to enter but not exit the garage, and its sends the message "this is garage belongs to..." after you enter instead of when your player name isn't the right one...any ideas?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if((newkeys == KEY_FIRE)&&(oldkeys != KEY_FIRE) && (IsPlayerInDynamicCP(playerid, Garage2Enter)))
if(strcmp(name,"Timmy_Hernandez")==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(GetPlayerVehicleID(playerid), -1775.9374, 1411.8651, 826.5721);//vehicle garage enter
SendClientMessage(playerid,0x1E90FFAA,"Welcome to your garage, Timmy_Hernandez!");
}
else
{
SetPlayerPos(playerid, -1775.9374, 1411.8651, 826.5721);//player garage enter
SendClientMessage(playerid,0x1E90FFAA,"Welcome to your garage, Timmy_Hernandez!");
}
if((newkeys == KEY_FIRE)&&(oldkeys != KEY_FIRE) && (IsPlayerInDynamicCP(playerid, Garage2Exit)))
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(GetPlayerVehicleID(playerid), -1786.8834, 1403.2548, 6.6779);//vehicle garage exit
}
else
{
SetPlayerPos(playerid, -1786.8834, 1403.2548, 6.6779);//player garage exit
}
}
else
{
SendClientMessage(playerid,0xD2691EAA,"this is garage belongs to Timmy_Hernandez.");
}
return 1;
}
Re: Problem with garage system -
mamorunl - 16.04.2012
If you got your code indented the same way in your Gamemode, I can see where you went wrong. You have misaligned all IF/ELSE statements.
To get a little overview: Your IF isPlayerInDynamicCP(playerid, Garage2Enter) ALSO includes the IF statement for the EXIT. It is in the same block.