-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from Cruze03/master
Added 2 new natives (Weapons_GetClientKnife and Weapons_SetClientKnife)
- Loading branch information
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#if defined _weapons_included_ | ||
#endinput | ||
#endif | ||
#define _weapons_included_ | ||
|
||
//Retrieves and stores client's knife entity name in 'sKnife'. returns 'weapon_knife' if selection is 'OwnKnife'. | ||
native void Weapons_GetClientKnife(int client, char[] sKnife, int Size); | ||
|
||
//Sets client's knife to what is stored in 'sKnife'. Throws Native Error if knife name isn't valid. Update = Store the 'sKnife' in client's mysql table? | ||
native void Weapons_SetClientKnife(int client, char[] sKnife, bool update); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
public int Weapons_GetClientKnife_Native(Handle plugin, int numparams) | ||
{ | ||
int client = GetNativeCell(1); | ||
if (client < 1 || client > MaxClients) | ||
{ | ||
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d).", client); | ||
} | ||
if(!IsClientInGame(client)) | ||
{ | ||
return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not in game.", client); | ||
} | ||
char KnifeName[64]; | ||
GetClientKnife(client, KnifeName, sizeof(KnifeName)); | ||
SetNativeString(2, KnifeName, GetNativeCell(3)); | ||
return 0; | ||
} | ||
|
||
public int Weapons_SetClientKnife_Native(Handle plugin, int numparams) | ||
{ | ||
int client = GetNativeCell(1); | ||
if (client < 1 || client > MaxClients) | ||
{ | ||
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d).", client); | ||
} | ||
if(!IsClientInGame(client)) | ||
{ | ||
return ThrowNativeError(SP_ERROR_NATIVE, "Client (%d) is not in game.", client); | ||
} | ||
char KnifeName[64]; | ||
GetNativeString(2, KnifeName, 64); | ||
bool update = !!GetNativeCell(3); | ||
SetClientKnife(client, KnifeName, true, update); | ||
return 0; | ||
} |