04-21-2008, 05:03 PM
Lock + Unlock
Vehicle [ Id ] ( Id's can be found on sa-mp wiki ) ( Do not type in a invalid id it will crash server, altough i could just do a invalid comment if id is incorrect ) ( rcon command )
Code:
if (strcmp(cmdtext, "/lock", true)==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,COLOR_RED,"You must be the driver to lock your vechicle!");
return 1;
}
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
}
}
SendClientMessage(playerid, COLOR_ORANGE, "Vehicle locked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
}
return 1;
}
if (strcmp(cmdtext, "/unlock", true)==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,COLOR_RED,"You must be the driver of the vechicle to unlock!");
return 1;
}
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
}
SendClientMessage(playerid, COLOR_ORANGE, "Vehicle unlocked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1057,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
}
return 1;
}Vehicle [ Id ] ( Id's can be found on sa-mp wiki ) ( Do not type in a invalid id it will crash server, altough i could just do a invalid comment if id is incorrect ) ( rcon command )
Code:
if(IsPlayerAdmin(playerid))
{
if(!strcmp(cmd, "/v", true))
{
new str[256], Float:x, Float:y, Float:z, id, tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Correct Usage: /v [id]");
id = strval(tmp);
GetPlayerPos(playerid, x, y, z);
CreateVehicle(id, x+2, y, z, 0, -1, -1, -1);
format(str, 256, "Got vehicle: %d", id);
SendClientMessage(playerid, COLOR_ORANGE, str);
return true;
}
}
![[Image: sig542.jpg]](http://www.ra3boards.com/sig_gen/sig542.jpg)