Returning a CMD! - 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)
+--- Thread: Returning a CMD! (
/showthread.php?tid=601772)
Returning a CMD! -
Compiler - 26.02.2016
I have a antifall command. Its fuction is to only Send the Player a Message but it also has a Variable and the Variable has the main function. When I do /antifall, it Send me the Message and the Varible performs its function but when I use return CMD_antifall( playerid ), it Sends me the message but the variable doesnt perform its function but the variable becomes 1 when it is 0 and 0 when it is 1. Why isnt it performing its function? Can anybody help!
Re: Returning a CMD! -
K0P - 26.02.2016
Lol,did you made any function for it?
Re: Returning a CMD! -
SyS - 26.02.2016
show code i think u may have returned multiple (semantic error bro)
Re: Returning a CMD! -
Compiler - 28.02.2016
I returned the Command while making a /settings command. Here is the Code:
Command:
PHP Code:
CMD:antifall( playerid )
{
if(Act[playerid] == 0)
{
Act[playerid] = 1;
SendClientMessage(playerid,-1,">>>"GREEN" Antifall Enabled!");
}
else if(Act[playerid] == 1)
{
SendClientMessage(playerid,-1,">>>"RED" Antifall Disabled!");
Act[playerid] = 0;
}
return 1;
}
Function of the Variable:
PHP Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(Act[playerid] == 1)
{
if(oldstate == PLAYER_STATE_DRIVER)
{
if(newstate == PLAYER_STATE_ONFOOT)
{
if(InCar[playerid] == 1)
{
PutPlayerInVehicle(playerid, WhatCar[playerid], Driver);
}
}
}
if(oldstate == PLAYER_STATE_PASSENGER)
{
if(newstate == PLAYER_STATE_ONFOOT)
{
if(InCar[playerid] == 1)
{
PutPlayerInVehicle(playerid, WhatCar[playerid], Passanger);
}
}
}
if(oldstate == PLAYER_STATE_ONFOOT)
{
if(newstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER)
{
InCar[playerid] = 1;
WhatCar[playerid] = GetPlayerVehicleID(playerid);
}
}
}
return 1;
}
The Settings Stock:
PHP Code:
stock ShowSettings (playerid)
{
new str[350];
new Antifal[40];
if (Act[playerid] == 1) format(Antifal, 40, GREEN"Enabled");
if (Act[playerid] == 0) format(Antifal, 40, RED"Disabled");
format(str, sizeof(str), "Antifall (%s{FFFFFF})", Antifal);
ShowPlayerDialog(playerid, DIALOGID_SETTINGS, DIALOG_STYLE_LIST, REDORANGE">> {FFFFFF}Account Settings", str, "OK", "Cancel");
return 1;
}
The Place where the command is returned:
PHP Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOGID_SETTINGS) {
if (!response) return 1;
if (response) { Timer1[playerid] = SetTimerEx("Settings", 50, true, "i", playerid);
switch (listitem)
{
case 0:
{
return CMD_god( playerid );
}
case 1:
{
return CMD_antifall( playerid );
}
}
}
}
return 1;
}
Please help me!
Re: Returning a CMD! -
SyS - 28.02.2016
Try it changing CMD_antifall to cmd_antifall im not sure though
Edit u made it like that 0 to become 1 and when 1 to become 0 so wat is problem??