Trying to make a toggle phone system -
Goldilox - 08.06.2013
This is how I did it.
pawn Код:
// on top
new power;
//OnPlayerConnect
power = 0;
// Making command now
CMD:poweron(playerid,params[])
{
if(PlayerInfo[playerid][Cell]<=1)return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone.");
if(power == 1){
SendClientMessage(playerid,COLOR_GREY,"Your phone is already on.");
}
else{
power == 1;
SendClientMessage(playerid,COLOR_WHITE,"You have turned your phone's power on.");
}
return 1;
}
If player doesn't have a cellphone it'll give him message. If the power is already on, it'll say "Your phone is already on." and if it's not it'll set power = 1 and give message that "You have turned your phone's power on." and every phone command like /call /text will check if the phone is on or not as above. But I get following warning. Seeking an effective help!
Код:
C:\Users\*******\*******\******\gamemodes\*****.pwn(1691) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Line 1691:
Re: Trying to make a toggle phone system -
mastermax7777 - 08.06.2013
else{
power == 1;
to
else{
power = 1;
please rep
Re: Trying to make a toggle phone system -
Goldilox - 08.06.2013
Sweet! Thanks bro. I've incremented your reputation by 1.
Re: Trying to make a toggle phone system -
random123 - 08.06.2013
Your code isn't going to work you need to make a player array or else when 1 player uses the command EVERYONES phone will turn off.
PHP код:
new bool:PhoneOn[MAX_PLAYERS];//we will use a bool here since it is more efficient to do so when possible
PhoneOn[playerid] = true; //put this in OnPlayerConnect so their phone is on when they spawn
CMD:poweron(playerid,params[])
{
if(PlayerInfo[playerid][Cell]<=1)return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone.");
if(PhoneOn[playerid] == true)
{
SendClientMessage(playerid,COLOR_GREY,"You have shut off your phone");
PhoneOn[playerid] = false;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Your phone is now on");
PhoneOn[playerid] = true;
}
return 1;
}
Let me know if you need help making this work with your /call and /text cmds
Re: Trying to make a toggle phone system -
Goldilox - 08.06.2013
Thanks Random for your correction, it's good now. Could you also help me out with getting rid of those warnings?
Код:
C:\Users\iSoomro\Desktop\TwD!!!\gamemodes\twdrp.pwn(4746) : warning 211: possibly unintended assignment
C:\Users\iSoomro\Desktop\TwD!!!\gamemodes\twdrp.pwn(4775) : warning 211: possibly unintended assignment
C:\Users\iSoomro\Desktop\TwD!!!\gamemodes\twdrp.pwn(4804) : warning 211: possibly unintended assignment
C:\Users\iSoomro\Desktop\TwD!!!\gamemodes\twdrp.pwn(4821) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Warnings.
Line 4746
pawn Код:
if(PhoneOn[playerid] = false) return SendClientMessage(playerid,COLOR_GREY,"Your phone is turned off!");
Line 4775
pawn Код:
if(PhoneOn[playerid] = false) return SendClientMessage(playerid,COLOR_GREY, "Your phone is turned off!");
Line 4804
pawn Код:
if(PhoneOn[playerid] = false) return SendClientMessage(playerid,COLOR_GREY,"You're phone is turned off.");
Line 4821
pawn Код:
if(PhoneOn[playerid] = false) return SendClientMessage(playerid,COLOR_GREY,"You're phone is turned off.");
Re: Trying to make a toggle phone system -
DobbysGamertag - 08.06.2013
pawn Код:
if(PhoneOn[playerid] == false)
Two == are needed
Re: Trying to make a toggle phone system -
Goldilox - 08.06.2013
Right! Thanks for your help guys!
Added reputation to everyone.