How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 24.06.2011
if (strcmp("/gearme", cmdtext, true, 10) == 0)
{
GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4);
GivePlayerWeapon(playerid, 24, 700);
GivePlayerWeapon(playerid, 31, 1400);
SetPlayerArmour(playerid, 100);
return 1;
}
For instance, after a player types /gearme, he/she can't use this command again unless they respawn/die.
(It's to keep people from entering /gearme over and over and over again.)
Re: How can I make this so that it can only be used once after each respawn? -
DaRealz - 24.06.2011
Quote:
Originally Posted by omgkillerzambies
if (strcmp("/gearme", cmdtext, true, 10) == 0)
{
GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4);
GivePlayerWeapon(playerid, 24, 700);
GivePlayerWeapon(playerid, 31, 1400);
SetPlayerArmour(playerid, 100);
return 1;
}
For instance, after a player types /gearme, he/she can't use this command again unless they respawn/die.
(It's to keep people from entering /gearme over and over and over again.)
|
WEll... im new to this kinda, but i might be able to help.
This might be wasting space in the script to do this, but this is how i do it:
put this at the top of the script
pawn Код:
new gearme; //or some other name
Then after, for your command, do this:
pawn Код:
if (strcmp("/gearme", cmdtext, true, 10) == 0)
{
if(gearme = 1)
{
SendClientMessage(playerid,0xFFFFFFFF,"You already geared youself !");
}
else if(gearme = 0)
{
GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4);
GivePlayerWeapon(playerid, 24, 700);
GivePlayerWeapon(playerid, 31, 1400);
SetPlayerArmour(playerid, 100);
gearme = 1; //This should make it so now, if u do it again, it will do the first thing where it says you already geared yourself
}
return 1;
}
then under OnPlayerDeath
pawn Код:
gearme = 0; //if you want to beable to /gearup again after you die
And on OnPlayerConnect
NOT TESTED | NOT SURE IF IT WORKS
Re: How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 24.06.2011
Thanks a lot! I'll give it a go tomorrow, but I have to catch a few zzz's before work.
Thanks again, I really appreciate it.
(I'm new to this also.)
Re: How can I make this so that it can only be used once after each respawn? -
linuxthefish - 24.06.2011
Quote:
Originally Posted by DaRealz
WEll... im new to this kinda, but i might be able to help.
This might be wasting space in the script to do this, but this is how i do it:
put this at the top of the script
pawn Код:
new gearme; //or some other name
Then after, for your command, do this:
pawn Код:
if (strcmp("/gearme", cmdtext, true, 10) == 0) { if(gearme = 1) { SendClientMessage(playerid,0xFFFFFFFF,"You already geared youself !"); } else if(gearme = 0) { GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4); GivePlayerWeapon(playerid, 24, 700); GivePlayerWeapon(playerid, 31, 1400); SetPlayerArmour(playerid, 100); gearme = 1; //This should make it so now, if u do it again, it will do the first thing where it says you already geared yourself } return 1; }
then under OnPlayerDeath
pawn Код:
gearme = 0; //if you want to beable to /gearup again after you die
And on OnPlayerConnect
NOT TESTED | NOT SURE IF IT WORKS
|
should be
Код:
new gearme[MAX_PLAYERS];
Re: How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 24.06.2011
Ah, yeah, thanks for that Linux.
As I said, I'll give it a go tomorrow.
I appreciate it very much so.
Re: How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 24.06.2011
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(133) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(150) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(207) : warning 211: possibly unintended assignment
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(207) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(211) : warning 211: possibly unintended assignment
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(211) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(217) : error 033: array must be indexed (variable "gearme")
Couldn't help myself, but going to bed now.
Re: How can I make this so that it can only be used once after each respawn? -
linuxthefish - 24.06.2011
Quote:
Originally Posted by linuxthefish
should be
Код:
new gearme[MAX_PLAYERS];
|
Quote:
Originally Posted by omgkillerzambies
Ah, yeah, thanks for that Linux.
As I said, I'll give it a go tomorrow.
I appreciate it very much so.
|
Quote:
Originally Posted by omgkillerzambies
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(133) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(150) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(207) : warning 211: possibly unintended assignment
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(207) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(211) : warning 211: possibly unintended assignment
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(211) : error 033: array must be indexed (variable "gearme")
C:\Users\Nanna\Desktop\SAMP\gamemodes\ni.pwn(217) : error 033: array must be indexed (variable "gearme")
Couldn't help myself, but going to bed now.
|
You should have a variable array thingy for each player, having a global variable will just allow the cmd to be used once by someone, and not everyone else.
EDIT: Colossus_'s post may be more helpful.
Re: How can I make this so that it can only be used once after each respawn? -
LZLo - 24.06.2011
PHP код:
new gearme[MAX_PLAYERS];
PHP код:
if (strcmp("/gearme", cmdtext, true, 10) == 0)
{
if(gearme[playerid] == 1)
{
SendClientMessage(playerid,0xFFFFFFFF,"You already geared youself !");
}
else
if(gearme[playerid] == 0)
{
GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4);
GivePlayerWeapon(playerid, 24, 700);
GivePlayerWeapon(playerid, 31, 1400);
SetPlayerArmour(playerid, 100);
gearme[playerid] = 1;
}
return 1;
}
after onplayerspawn - there is no matter why it's good to use onplayerdisconnect, because after the connection the player spawns down
PHP код:
gearme[playerid] = 0;
check this out
Re: How can I make this so that it can only be used once after each respawn? -
iPLEOMAX - 25.06.2011
In your CMD:
pawn Код:
if(GetPVarInt(playerid, "gearme") != 1) // 1 means its already used.
{
SetPVarInt(playerid, "gearme", 1); //Setting to 1, which lets the cmd to detect it on next use. See Above^
GameTextForPlayer(playerid, "Cheat found! Multiple weapons and full armour given.", 5000, 4);
GivePlayerWeapon(playerid, 24, 700);
GivePlayerWeapon(playerid, 31, 1400);
SetPlayerArmour(playerid, 100);
} else SendClientMessage(playerid, 0xFFFFFFFF, "You can only use it again after death.");
In OnPlayerDeath:
pawn Код:
SetPVarInt(playerid, "gearme", 0); // Setting it to normal.
In OnPlayerDisconnect:
pawn Код:
SetPVarInt(playerid, "gearme", 0); // Setting it to normal.
Hope this helps.
Re: How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 26.06.2011
Looks like it worked, man. Thanks a lot.
Re: How can I make this so that it can only be used once after each respawn? -
omgkillerzambies - 26.06.2011
@iPLEOMAX
Code worked, however when I enter /gearme it says unknown command.
It's weird though, because it still works. Like I get the guns and everything.
Re: How can I make this so that it can only be used once after each respawn? -
iPLEOMAX - 26.06.2011
Quote:
Originally Posted by omgkillerzambies
@iPLEOMAX
Code worked, however when I enter /gearme it says unknown command.
It's weird though, because it still works. Like I get the guns and everything.
|
Add this in your
cmd at the end:
I think you forgot this..