[+REP]Server restarting randomly and bug
#1

Heres my script for DCMD:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    //dcmd//
    //General commands//
    dcmd(kill,4,cmdtext); // /kill
    dcmd(ahelp,5,cmdtext); //Admin Commands
    dcmd(restoreme,9,cmdtext); //VIP "Restore"
    dcmd(vipkill,7,cmdtext); //VIP /kill
    dcmd(givemoney,9,cmdtext); //Give Money
    dcmd(psay,4,cmdtext);
    return 1;


    return SendClientMessage(playerid,COLOR_RED,"Wrong command. This command is not found on MWFFA. Type /help for a list of commands.");
}

dcmd_kill(playerid)
{
    new pname[24];
    new cmdreason[128];
   
    SendClientMessage(playerid, 0xEE82EEFF, "You have killed yourself using /kill and have lost: $400.");
    SendClientMessageToAll(0xEE82EEFF, "%s has Killed them self using /kill. Reason: %s",pname,cmdreason);
    return 0;
}

dcmd_ahelp(playerid)
{
    if(IsPlayerLuxAdminLevel(playerid, 1))
    {
    SendClientMessage(playerid, COLOR_YELLOW, "To See Your Admin Commands, Do the following:");
    SendClientMessage(playerid, COLOR_YELLOW, "Use /level <Your Admin Level Here> to see your admin commands");
    }
    else SendClientMessage(playerid, COLOR_RED, "ERROR: You do Not Have Enough rights to execute this command");
    return 0;
}

dcmd_restoreme(playerid)
{
    if(IsPlayerVipType(playerid,3))
    {
    SendClientMessage(playerid, 0x32CD32FF, "Your Health, Armour, and Vehicle Health has been Restored");
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100.0);
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle, so your vehicle health is not restored. But your health and armour is.");
    RepairVehicle(GetPlayerVehicleID(playerid));
    }
    else SendClientMessage(playerid, COLOR_RED, "ERROR: You do not have enough rights to execute this command");
    return 0;
}

dcmd_vipkill(playerid)
{
    if(IsPlayerVipType(playerid,2))
    {
    SendClientMessage(playerid, 0x32CD32FF, "/vipkill is a special /kill. It is special because you don't lose your money if you use it");
    SetPlayerArmour(playerid, 0.0);
    SetPlayerHealth(playerid, 0);
    }
    else SendClientMessage(playerid, COLOR_RED, "ERROR: You do not have enough rights to execute this command");
    return 0;
}

dcmd_givemoney(playerid)
{
    new ID, amount;
    new string[128];
    new pname[24];
   
    SendClientMessage(playerid,COLOR_GREEN,"Money Given");
    format(string,sizeof(string),"You have given $%d of your own money to %s(%d).",amount,pname,ID);
    SendClientMessage(playerid,COLOR_YELLOW,string);
    GivePlayerMoney(playerid,-amount);

    SendClientMessage(ID,COLOR_GREEN,"[[_Money Received_]]");
    format(string,sizeof(string),"You have been given $%d by %s(%d). Make sure you thank them.",amount,pname,playerid);
    SendClientMessage(ID,COLOR_YELLOW,string);
    GivePlayerMoney(ID,amount);
    return 0;
}

dcmd_psay(playerid)
{
    new cmdreason[128];
   
    SendClientMessageToAll(COLOR_YELLOW, "[PLAYER SAY]%s",cmdreason);
    return 0;
}
Problem: Server randomly restarting on certain commands... /givemoney always only gives $0, and other stuff.


PLEASE HELP..


+REP

And heres my chat log...
Код:
[19:50:24] {FFFFFF}SA-MP {EE5555}0.3d-R2 {FFFFFF}Started

[19:50:27] Connecting to 216.172.106.18:7787...

[19:50:27] Connected. Joining the game...

[19:50:27] NBTDM SYSTEM You have been Automatically Logged in | Account: Premium | Level 10 - Professional Admin |

[19:50:27] [xXx]CaptainPrice has joined the server

[19:50:31] Connected to {EE5555}Modern Warfare FFA

[19:50:33] You have spawned. Watch out. Note that there is no Anti-Spawn Kill.

[19:50:49] Lost connection to the server. Reconnecting..

[19:50:49] The server is restarting..

[19:50:49] Connecting to 216.172.106.18:7787...

[19:50:50] Connected. Joining the game...

[19:50:50] NBTDM SYSTEM You have been Automatically Logged in | Account: Premium | Level 10 - Professional Admin |

[19:50:50] [xXx]CaptainPrice has joined the server

[19:50:53] Connected to {EE5555}Modern Warfare FFA

[19:50:54] You have spawned. Watch out. Note that there is no Anti-Spawn Kill.

[19:50:56] /vipkill is a special /kill. It is special because you don't lose your money if you use it

[19:50:56] Sad for you, But your killer got 2 score! You lost 2 Score.

[19:50:56] [NOTE]Every time you kill someone, You get +2 Score.

[19:50:56] The person who dies will also lose $500.

[19:51:00] You have spawned. Watch out. Note that there is no Anti-Spawn Kill.

[19:51:18] Lost connection to the server. Reconnecting..

[19:51:18] The server is restarting..

[19:51:18] Connecting to 216.172.106.18:7787...

[19:51:19] Connected. Joining the game...

[19:51:19] NBTDM SYSTEM You have been Automatically Logged in | Account: Premium | Level 10 - Professional Admin |

[19:51:19] [xXx]CaptainPrice has joined the server

[19:51:21] Connected to {EE5555}Modern Warfare FFA

[19:51:22] You have spawned. Watch out. Note that there is no Anti-Spawn Kill.

[19:52:17] Money Given

[19:52:17] You have given $0 of your own money to (0).

[19:52:17] [[_Money Received_]]

[19:52:17] You have been given $0 by (0). Make sure you thank them.

[19:52:37] Money Given

[19:52:37] You have given $0 of your own money to (0).

[19:52:37] [[_Money Received_]]

[19:52:37] You have been given $0 by (0). Make sure you thank them.
Reply
#2

When you make a new variable, you need to assign it a value.

pawn Код:
new name[24];
GetPlayerName(playerid, name, sizeof name);
Just because you make a new command doesn't mean it will have all the parameters set.

__________________________________________________ ____________________________

I highly recommend zcmd. It's fast and easy to use:

https://sampforum.blast.hk/showthread.php?tid=91354

Here's an example:

pawn Код:
CMD:kill(playerid, params[])
{
    new pname[24];
    GetPlayerName(playerid, pname, 24);
    SendClientMessage(playerid, 0xEE82EEFF, "You have killed yourself using /kill and have lost: $400.");
    SendClientMessageToAll(0xEE82EEFF, "%s has Killed them self using /kill. Reason: %s",pname,params);
    SetPlayerHealth(playerid, 0);
    return 1;
}
You don't have to keep adding it in OnPlayerCommandText, WAY fast than zcmd, has params, etc.
Reply
#3

The problem could be that your returning it 0, try returning it by 1
pawn Код:
return 1;
Reply
#4

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
The problem could be that your returning it 0, try returning it by 1
pawn Код:
return 1;
or yours sniper fixed the name problem... But /psay still restarts server and /givecash still only gives $0
Reply
#5

You need to use something like sscanf for them.
Reply
#6

ok ill do that + try
Reply
#7

pawn Код:
dcmd_psay(playerid,params[])
{
    new cmdreason[128];
    format(params,sizeof params, "[PLAYER SAY]%s",params);
    SendClientMessageToAll(COLOR_YELLOW,cmdreason);
    return 0;
}
Reply
#8

/psay still doesn't work.
Reply
#9

pawn Код:
dcmd_psay(playerid,params[])
{
    new string[128];
    format(string,sizeof string, "[PLAYER SAY]%s",params);
    SendClientMessageToAll(COLOR_YELLOW,string);
    return 0;
}
I highly recommend reading the wiki..
Reply
#10

pawn Код:
dcmd_psay(playerid, params[])
{
    format(params, 128, "[PLAYER SAY] %s", params);
    SendClientMessageToAll(COLOR_YELLOW, params);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)