Preventing some commands in a different world -
Kayla.S - 01.06.2010
Hi,
I'm wondering how can I prevent people from using some commands if a player is in a certain world. But can use it any other time. For example my /s and /l commands. I'm wanting to disable them only in virtual world 4.
http://pastebin.com/jBFFPPdw
One more question, how can I display the pawn code properly on the forums?
Thanks.
Re: Preventing some commands in a different world -
Niixie - 01.06.2010
Use [pawn
.] [/pawn
.] for small pawn codes.
And use
pawn Код:
new PlayerVW = GetPlayerVirtualWorld(playerid);
if(!PlayerVW == 4)
{
// rest of the command
}
else
{
// what happends when his in vworld 4
}
Add that to your commands.
Re: Preventing some commands in a different world -
Kayla.S - 01.06.2010
Thank you Niixie.
Ok I tried it but for some reason it won't let me use any command no matter the VW I'm in. Obviously I must have put it in the wrong way. >.< Any ideas?
I used this short command as an example to test it.
pawn Код:
if(!strcmp("/heal", cmdtext, true))
{
new PlayerVW = GetPlayerVirtualWorld(playerid);
if(PlayerVW == 4)
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100.0);
}
else
{
SendClientMessage(playerid, 0xFB0000FF,"SERVER: You cannot use this command here.");
return 1;
}
Re: Preventing some commands in a different world -
Conroy - 01.06.2010
pawn Код:
if(!strcmp("/heal", cmdtext, true))
{
new PlayerVW = GetPlayerVirtualWorld(playerid);
if(PlayerVW == 4) {
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100.0);
}
else {
SendClientMessage(playerid, 0xFB0000FF,"SERVER: You cannot use this command here.");
}
return 1;
}
Re: Preventing some commands in a different world -
Kayla.S - 01.06.2010
It worked. Thank you guys.
Re: Preventing some commands in a different world -
Kayla.S - 02.06.2010
Ok I got it working for all my commands except for my /s (save) and /l one. When I use the code stated above me I get errors meaning I'm missing a bracket or something. I've tried and with no success. If anyone can point me in the right direciton that would be great. Thank you.
pawn Код:
if(!strcmp(cmdtext, "/s",true) || !strcmp(cmdtext,"/sp",true)){ if (IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid), SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), SavePos[playerid][sA]);
}else {
GetPlayerPos(playerid, SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
GetPlayerFacingAngle(playerid, SavePos[playerid][sA]);
}SavePos[playerid][SavedPos] = 1;
return SendClientMessage(playerid, 0xFFFFFFAA, "Position saved! Use /l To Return");
}
if(!strcmp(cmdtext, "/l",true) || !strcmp(cmdtext,"/lp",true))
{
if (SavePos[playerid][SavedPos] == 0) return SendClientMessage(playerid, 0xFFFFFFAA, "Position Not Saved! Use /s First!");
if (IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(GetPlayerVehicleID(playerid), SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
SetVehicleZAngle(GetPlayerVehicleID(playerid), SavePos[playerid][sA]);
} else {
SetPlayerPos(playerid, SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
SetPlayerFacingAngle(playerid, SavePos[playerid][sA]);
}
return SendClientMessage(playerid, 0xFFFFFFAA, "You have teleported to the last position you have saved.");
}
Re: Preventing some commands in a different world -
Niixie - 02.06.2010
You didnt put it in?
Re: Preventing some commands in a different world -
Kayla.S - 02.06.2010
I tried but I'm obviously putting it in wrong:/ Sorry I should have showed you exactly how I had put it. I know by just looking at it it's wrong, but I can't figure out where to fit it in. Here's how mine looks.
pawn Код:
if(!strcmp(cmdtext, "/s",true) || !strcmp(cmdtext,"/sp",true)){ if (IsPlayerInAnyVehicle(playerid))
{
new PlayerVW = GetPlayerVirtualWorld(playerid);
if(PlayerVW == 4) {
SendClientMessage(playerid, 0xFB0000FF,"SERVER: You cannot use this command here.");
}
else {
GetVehiclePos(GetPlayerVehicleID(playerid), SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), SavePos[playerid][sA]);
}else {
GetPlayerPos(playerid, SavePos[playerid][sX], SavePos[playerid][sY], SavePos[playerid][sZ]);
GetPlayerFacingAngle(playerid, SavePos[playerid][sA]);
}SavePos[playerid][SavedPos] = 1;
return SendClientMessage(playerid, 0xFFFFFFAA, "Position saved! Use /l To Return");
}
Re: Preventing some commands in a different world -
IcyBlight - 02.06.2010
Instead of doing what they said, just add this at the FIRST line in the script.
pawn Код:
if(GetPlayerVirtualWorld(playerid) != 4) return SendClientMessage(playerid, COLOR, "You can't use this command here!");
It's much easier.