Medical record - please help!
#1

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_mysql>

#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_DB   "database"
#define MYSQL_PASS "123123"
#define MAX_STRING 255

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}


public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
    mysql_debug(1);
    if(mysql_ping()==1) print("MySQL connection is still alive!");
    // ...
    if(mysql_ping()==-1) print("MySQL connection is dead!");
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new query[64];
    format(query,sizeof(query),"SELECT * FROM sys WHERE Username='%s'",GetName(playerid));
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() == 0)
    {
        format(query, sizeof(query), "INSERT INTO sys (Username) VALUES ('%s')", GetName(playerid));
        mysql_query(query);
        SendClientMessage(playerid,0xFFFFFF,"Hello there new pal!");
    }
    else
    {
        return SendClientMessage(playerid,0xFFFFFF,"Welocome back!");
    }
    mysql_free_result();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], tmp[256], idx;
    cmd = strtok(cmdtext,idx);
    if(strcmp(cmd, "/addmd", true) == 0)
    {
        new tmp2[256];
        tmp = strtok(cmdtext, idx);
        tmp2 = strrest(cmdtext, idx);
        if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, 0xFFFFFF, "USAGE: /addmd [playerid] [text]");
        new q[128];
        format(q, sizeof(q), "INSERT INTO sys (username,medical) VALUES ('%s','\n%s')",GetName(strval(tmp)), tmp2);
        mysql_query(q);
        return 1;
    }
    if(strcmp(cmd, "/checkmd", true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFF,"USAGE: /checkmd [playerid]");
        new str[128],qq[128];
        format(qq,sizeof(qq),"SELECT * FROM sys WHERE Username='%s'", GetName(strval(tmp)));
        mysql_query(qq);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            new info[150];
            mysql_fetch_row_format(info);
            format(str, sizeof(str), "COMPUTED MEDICAL RECORDS SYSTEM\n\nNAME: %s\nSTATE: UNITED STATES OF AMERICA\nMEDICAL RECORDS: \n %s", GetName(strval(tmp)), info);
            ShowPlayerDialog(playerid,6,DIALOG_STYLE_MSGBOX,"MEDICAL RECORD SYSTEM",str,"","");
        }
        else
        {
            SendClientMessage(playerid, 0xFFFFFF, "Doesn't exist.");
        }
        mysql_free_result();
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

stock GetName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    return pName;
}
stock strrest(const string[],index)
{
    new length = strlen(string),offset = index,result[256];
    while((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index],index++;
    result[index - offset] = EOS;
    if(result[0] == ' ' && string[0] != ' ') strdel(result,0,1);
    return result;
}
strtok(const string[], &index,seperator=' ')
{
    new length = strlen(string);
    new offset = index;
    new result[MAX_STRING];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }

    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
        index++;
    }
    return result;
}
I am trying to think how to do it and I can't make it, PLEASE help me and do it for me!
I want on /addmd that it will add more medical record to the player and to the database (working)
But on /checkmd it is showing the first number only or something and I want it to show all the medical record you have, please do that for me I don't know how to do it.
Reply
#2

please explain it betteR?
Reply
#3

/addmd should add a medical record to the player which will appear on /checkmd, everytime some1 will do /addmd and add a medical record it will update with more record, and all the records will appear on /checkmd, please do that for me, the codes above it's what I tried to do, but it's not working, please help me, I need it to recognize the name and take the medical records and list them on /checkmd.
Reply
#4

bump
Reply
#5

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)