Command failure? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command failure? (
/showthread.php?tid=150614)
Command failure? -
-Rebel Son- - 27.05.2010
Код:
if(!strcmp(cmdtext,"/arm",true)) {
new classid;
if(IsPlayerInCheckpoint(playerid))
{
if(classid == 0 || classid == 1 || classid == 2)
{
SendClientMessageToAll(COLOR_GREEN,"Team 1 has planted their bomb!");
}
if (classid == 3 || classid == 4 || classid == 5)
{
SendClientMessageToAll(COLOR_GREEN,"Team 2 has planted their bomb!");
}
else
{
SendClientMessage(playerid,COLOR_RED,"Your Not in the checkpoint!");
}
}
return 1;
}
Suppost to check if the player is in a checkpoint. then announce if that team set their bomb. but so far. you type /arm outside of a checkpoint. it does nothing. do /arm inside a checkpoint ti says im not in one. any idea of how i got this backwards?
Re: Command failure? -
coole210 - 27.05.2010
IsPlayerInCheckpoint needs to be like this:
if(IsPlayerInCheckpoint(playerid) == checkpointid)
Re: Command failure? -
-Rebel Son- - 27.05.2010
There is no checkpoint id's.... im not using a streamer
Re: Command failure? -
Toni - 27.05.2010
Quote:
Originally Posted by _Ч§hмf†ҐЧ™_
There is no checkpoint id's.... im not using a streamer
|
yes but every checkpoint still needs a ID to be assigned to it so it can verify that its THAT checkpoint that they are at
Re: Command failure? -
-Rebel Son- - 27.05.2010
And how would i do that?
Код:
cp1 = CreateCheckpoint
like that?
Re: Command failure? -
Nero_3D - 27.05.2010
GUYS PLEASE STOP TELLING BULLSHIT, ups caps
SetPlayerCheckpoint only returns 1 if the checkpoint was created and 0 for not
IsPlayerInCheckpoint only checks if the player is in the checkpoint (and only one at the same time can exist)
Topic:
You got a bracket problem and the class thing wont work because you create the variable classid local (and never change it) so it is always zero
Use gTeam, the native team functions or the new pVars
Here an example with pVars (because I like friendly fire - the native function disable it

)
pawn Код:
//These macros will overwrite the existing native functions!
#define SetPlayerTeam(%0,%1) SetPVarInt(%2, "TEAM_VAR", %1)
#define GetPlayerTeam(%0) GetPVarInt(%0, "TEAM_VAR")
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
switch(classid)
{
case 0..2: SetPlayerTeam(playerid, 1); //Team 1
case 3..5: SetPlayerTeam(playerid, 2); //Team 2
}
}
pawn Код:
//OnPlayerCommandText
if(!strcmp(cmdtext,"/arm",true))
{
if(IsPlayerInCheckpoint(playerid))
{
if(GetPlayerTeam(playerid) == 1)
{
SendClientMessageToAll(COLOR_GREEN,"Team 1 has planted their bomb!");
} else { //if he isnt in team 1 he must be in team 2
SendClientMessageToAll(COLOR_GREEN,"Team 2 has planted their bomb!");
}
} else {
SendClientMessage(playerid,COLOR_RED,"Your Not in the checkpoint!");
}
return 1;
}
Re: Command failure? -
-Rebel Son- - 27.05.2010
Ok i understand it now. And this server will have two checkpoints. but only team 1 see's theirs. and team two see's theirs. will this still do the same?
EDIT: it works!
Also, how would i make a command only useable if it's near a certain cord?
Re: Command failure? -
Nero_3D - 27.05.2010
Quote:
Originally Posted by _Ч§hмf†ҐЧ™_
Also, how would i make a command only useable if it's near a certain cord?
|
use
IsPlayerInRangeOfPoint (example included)
Re: Command failure? -
-Rebel Son- - 27.05.2010
mmk, and how would i make it have a point for each team, use gTeam?
Re: Command failure? -
Nero_3D - 27.05.2010
pawn Код:
public OnPlayerSpawn(playerid)
{
if(GetPlayerTeam(playerid) == 1)
{
SetPlayerCheckpoint(playerid, X, Y, Z);
} else {
SetPlayerCheckpoint(playerid, X, Y, Z);
}
}
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPlayerTeam(playerid) == 1)
{
//code for team 1
} else {
//code for team 2
}
}
just replace GetPlayerTeam(playerid) with gteam[playerid]