Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <string.h>
- #include "sampgdk.h"
- void SAMPGDK_CALL PrintTickCountTimer(int timerid, void *params) {
- //sampgdk::logprintf("Tick count: %d", GetTickCount());
- char message[MAX_CLIENT_MESSAGE];
- sprintf(message, "Hello there with timer id %d!", timerid);
- SendClientMessageToAll(-1, message);
- }
- PLUGIN_EXPORT bool PLUGIN_CALL MyHttpResponse(int index, int response_code, char data[])
- {
- SendClientMessageToAll(0xFFFFFFFF, "HTTP response callback");
- char showdata[256];
- sprintf(showdata, "Index: %d ResponseCode: %d Data: %s", index, response_code, data);
- SendClientMessageToAll(-1, showdata);
- return true;
- }
- void SAMPGDK_CALL OnHTTPResponse(int index, int response_code, char data[])
- {
- SendClientMessageToAll(0xFFFFFFFF, "OnHTTPResponse");
- char showdata[256];
- sprintf(showdata, "Index: %d ResponseCode: %d Data: %s", index, response_code, data);
- SendClientMessageToAll(-1, showdata);
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
- //SetTimer(5000, true, PrintTickCountTimer, 0);
- return true;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect(int playerid) {
- SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the HelloWorld server!");
- return true;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerRequestClass(int playerid,int classid) {
- SendClientMessage(playerid, 0xFFFFFFFF, "OnPlayerRequestClass");
- return true;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerText(int playerid, const char * text)
- {
- SendClientMessage(playerid, -1, "Someone texted");
- SendClientMessageToAll(-1, "Someone texted - all");
- return true;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerEnterVehicle(int playerid, int vehicleid, bool ispassenger)
- {
- if (ispassenger == true)
- {
- SendClientMessage(playerid, -1, "You enter as passenger");
- }
- else
- {
- SendClientMessage(playerid, -1, "You enter as driver");
- }
- return 1;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerCommandText(int playerid,
- const char *cmdtext) {
- if (strcmp(cmdtext, "/hello") == 0)
- {
- char name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- char message[MAX_CLIENT_MESSAGE];
- sprintf(message, "Hello, %s!", name);
- SendClientMessage(playerid, 0x00FF00FF, message);
- sampgdk_SetPlayerPos(playerid, 0, 0, 0);
- return true;
- }
- if (strcmp(cmdtext, "/http") == 0)
- {
- SendClientMessage(playerid, -1, "http command send");
- HTTP(playerid, HTTP_GET, "localhost/test/old_index.php?name=ted", "MyHttpResponse");
- return true;
- }
- return false;
- }
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
- return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
- sampgdk::logprintf(" * Test plugin was loaded.", ppData);
- return sampgdk::Load(ppData);
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload() {
- sampgdk::Unload();
- }
- PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
- sampgdk::ProcessTick();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement